I am working with the Solr index (v1.4.1), which has a field that stores serialized JSON. The following is an example of JSON stored in the "json" field in a document in Solr .
{
"uri": "http://localhost/individual/n503",
"name": "Smith, Richard",
"title": "Programming CIO",
"items": [{
"uri": "http://localhost/individual/n1873",
"type": "http://localhost/individual/book"
}]
}
I would like to request this serialized JSON field for the existence of a URI (e.g., http://localhost/individual/n1873). I am using Scala with SolrJ (v1.4.1) to query for results. The function is as follows:
def documentsForUri(uri: String) = {
var query = new SolrQuery();
query.setQuery( "json:" + uri )
var rsp = solr.query( query )
rsp.getResults()
}
Passing uri = "http://localhost/individual/n1873"to the function, we get 0 documents. I tried changing the ":" to "\:", and that didn't seem to help. In my schema.xml, I tried to define the field as solr.StrFieldand solr.TextField. For instance:
<types>
...
<fieldType name="text" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100"/>
...
</types>
<solrQueryParser defaultOperator="OR"/>
, , :
<fields>
...
<field name="json" type="text" indexed="true" stored="true" multiValued="false" required="false"/>
...
</fields>
:
<fields>
...
<field name="json" type="text_ws" indexed="true" stored="true" multiValued="false" required="false"/>
...
</fields>
uri ( "\" ) uri ( ":" ).
, ? "" SQL- , JSON .