6

below is the json sample i have imported to solr where id is unique and json_doc field contains whole json.

{ "id" : "cust_123", "json_doc" : "{ "\first_name\":\"xyz\", \"last_name\":\"ABC\", \"address\":\"#s3,Apple store,New York,USA}\" }" }

Now i want to search within the json document like Apple store as query or New york as query or USA .... and i should get the document ...

Want help to define schema.xml for this kind of request.

if you use space tokenizer then it will tokenize on space ... so if i will search for "apple store" then it will not match ....

Please help me

2
  • 1
    Is there some reason why you indexed the whole JSON in a single field? Normally & Naturally & Intuitively: you're supposed to split the JSON to separate fields. Commented Apr 17, 2012 at 12:33
  • because if my json documents changes .. i dont want to add the fields in the schema .. and if i have different json documents like customer info document, address info document or order info document or wish list info document ..... and tomorrow i have to add the page view history document for user then ... Commented Apr 18, 2012 at 7:03

1 Answer 1

5

Here's how to index JSON documents: http://wiki.apache.org/solr/UpdateJSON

And here's how to get search results in a JSON doc: http://wiki.apache.org/solr/SolJSON

If you, on the other hand, have some weird requirement to store the whole document in a single field please tell...

Sign up to request clarification or add additional context in comments.

19 Comments

thanks for respond ... yes .. i want to store whole json document in the filed ... and i am very much confused about the schema ...
plz help on the following issue ... confused only for right schema
You wont be able to do fast searches with "whole JSON in a single field" setup. The whole point of schema is that you "tell" Solr which fields are going to be searched, so it can build fast access data structure with those fields' values. So, I don't see a reason against adding those fields in schema. Especially if you can use dynamic fields: wiki.apache.org/solr/SchemaXml#Dynamic_fields
thanks for your reply. but here i have 2 questions 1.Is it possible to get custom tokenizer which will create tokens based on "( double quote ) or any other delimiter ? i know i can apply filter with payload delimiter or something ... Any suggestion/idea ????
2.i have to dump all the fields i want's to use for searching.so it's like sql table defining a column and then get result. but if in sql table you are having a blob field contains the text and you wants to search anything then you dont have to define so many things ... same objective i want to achieve .. you just dump your document and search within that document ... Any input for this kind of request ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.