cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing JSON

tgmweb
Champ in-the-making
Champ in-the-making
I have JSON objects stored in my repository, but none of them are indexed - which would be *really* useful.

I don't want to convert the to text/plain, I just want them indexed.

When I do a search for +TEXT:"nint" - they are all listed, and when I list /alfresco/service/mimetypes, sure enough, application/json is listed as:

No extractors
Transformable To: Cannot be transformed into anything else
Transformable From: Cannot be generated from anything else

How can I fix that - it just needs to be transformed in text/plain to get indexed surely?
3 REPLIES 3

mrogers
Star Contributor
Star Contributor
Yes you could simply index the JSON as plain text.   However you are still searching by full text.   

Another approach that may (or may not) be applicable is to have a metadata extractor that reads your JSON data and stores your important values as properties,   that way you are not using text comparison.

tgmweb
Champ in-the-making
Champ in-the-making
Thanks for the reply. You're probably right, it would be nice to search on a key and not just plain text.

I thought I could do this manually using webscripts (extracting the json object and manually creating the "properties"), but it appears the JSON object is only available when the webscript receives an application/json request header. Is that right?

The docs state:
The JSON Object API provides the ability to programmatically traverse JSON documents, where the root of the document is either a JSON array or a JSON object. The Web Script Framework, if instructed, supplies one of two root object type named json to the web script, depending on the root of the JSON document.

"If instructed": how do I "instruct" the webscript to include those root objects? It's obviously instructed automatically where the request header has application/json, but can I "instruct it" myself?

I don't want to send the script any json, because the json object is actually in the repository already.

tgmweb
Champ in-the-making
Champ in-the-making
Just in a rare case that anyone is interested, whilst I couldn't see a way to get the JSON object using the built ins, I could convert the json content into a native javascript object by doing:

jsObject = jsonUtils.toObject(node.properties["cm:content"].getContent());

I could then loop through the object and add the key/values manually.