0

I have indexed two json documents into Solr, and when I get the response am I recieving both documents - how to differentiate the two documents and store the documents separately?

mbjorgan
  • 328
  • 2
  • 12
  • did not understand your question completely ! Is this related to any how related with uniqueness of documents which i already answered here for you http://stackoverflow.com/questions/38090847/reindexing-json-object-into-solr-by-adding-only-unique-elements/38091229#38091229 Can you elaborate ? – Saurabh Chaturvedi Jul 05 '16 at 15:30
  • how to get the all the indexed documents as resultSet as we get in jdbc when we execute a sql query..as I need to add the fields to datatable as row wise..i hope you got it – sachin kumar Jul 06 '16 at 07:25
  • 1
    please re-phrase your question correctly as it helps you find more good answers, btw i have posted my answer below . – Saurabh Chaturvedi Jul 06 '16 at 07:47

2 Answers2

0

You need to define a (unique) key when indexing the json-documents - this key being either mandatory or not. This could be done in schema.xml or managed-schema, if not already done. Further on would you have to search for this key in the query for fetching the wanted document.

This can be compared with querying for a unique primary key in SQL and traditional databases. A tuple/record, uniquely defined by the primary key, would in this scenario be equivalent with the json documents.

Assuming two documents with respective unique id 1 and 2 - can you fetch document 1 by searching forq=id:1 in the Solr Admin-UI - if you want the document with id 1. I'm afraid I don't know how to do this is Solrj or by QueryResponse.

Management of where documents are stored in Solr is not supported - it is more or less black-boxed. This should however not be a problem considering your situation as long as you specify the query correctly.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mbjorgan
  • 328
  • 2
  • 12
  • how to get the all the indexed documents as resultSet as we get in jdbc when we execute a sql query..as I need to add the fields to datatable as row wise..i hope you got it – – sachin kumar Jul 06 '16 at 07:26
0

Look here for a link that tells how to use Solr 6 as a JDBC dataSource . Better if you use Solr 6 if you want to utilize Solr more as a data source rather than an index source as it has enhanced SQL level features and hence, serves the purpose best . Here is the link https://sematext.com/blog/2016/04/26/solr-6-as-jdbc-data-source/ . Let me know if that helps you :) .

Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39