I do a full-import and I get the following response for the below command
http://localhost:8983/solr/karan/dataimport?command=full-import&commit=true&clean=false
But when I run the following snippet
public class SolrJSearcher {
public static void main(String[] args) throws SolrServerException, IOException {
SolrClient solr = new HttpSolrClient("http://localhost:8983/solr/karan");
SolrQuery query = new SolrQuery();
query.set("q", "karan");
QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
System.out.println(results.get(i));
}
}
}
I get no results even though two rows are there.If I change the q to : I get two results without the name karan.Can you please clarify what is going wrong in this If I try in the sample project techproducts with the same changes I get the results as expected.
Solrconfig.xml
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
data-config.xml
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/greed"
user="root"
password="kalkoti"/>
<document>
<entity name="id"
query="select id,name from testing">
</entity>
</document>
</dataConfig>
I have created the collection karan using
solr create -c karan
Response from full-import
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">12</int>
</lst>
<lst name="initArgs">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</lst>
<str name="command">full-import</str>
<str name="status">idle</str>
<str name="importResponse"/>
<lst name="statusMessages">
<str name="Total Requests made to DataSource">1</str>
<str name="Total Rows Fetched">2</str>
<str name="Total Documents Processed">2</str>
<str name="Total Documents Skipped">0</str>
<str name="Full Dump Started">2015-07-06 13:55:26</str>
<str name="">
Indexing completed. Added/Updated: 2 documents. Deleted 0 documents.
</str>
<str name="Committed">2015-07-06 13:55:26</str>
<str name="Time taken">0:0:0.431</str>
</lst>
</response>
You aren't specifying what fields should be written to in your data-config.xml file. See https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the+Data+Import+Handler
You haven't given us your full schema.xml or solrconfig.xml files, so it is hard to tell you exactly what to do, but Solr uses the select request handler as default, which uses the text field as the default search field. Meaning you will need to map whatever database column contains the term karan to the text field.
Related
The following query works well for me
http://[]:8983/solr/vault/select?q=VersionComments%3AWhite
returns all the documents where version comments includes White
I try to omit the field name and put it as a default value as follows :
In solr config I write
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">PackageName</str>
<str name="df">Tag</str>
<str name="df">VersionComments</str>
<str name="df">VersionTag</str>
<str name="df">Description</str>
<str name="df">SKU</str>
<str name="df">SKUDesc</str>
</lst>
I restart the solr and create a full import.
Then I try using
http://[]:8983/solr/vault/select?q=White
(Where
http://[]:8983/solr/vault/select?q=VersionComments%3AWhite
still works)
But I dont get the document any as answer.
What am I doing wrong?
As far as I know you should only have the <str name="df"></str> declared once in your requestHandler
Typically what I do is copy all the fields that i want to search into a default search field called text.
schema.xml:
<copyField source="name_t" dest="text"/>
solrconfig.xml
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="q">*:*</str>
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
</lst>
</requestHandler>
If this is not good enough, you can always search other fields using a dismax search with the qf declaration like so:
http://localhost:8983/solr/vault/select/?q= White&defType=dismax&qf=PackageName+Tag+VersionComments+VersionTag+Description+SKU+SKUDesc
I like to channel Solr search results at query time. For example I have three channels: products, faq and other_docs. All within the same Solr core with the same fields filled. What I would like to acceive is to have Solr group the results "channel" for me.
Sample database (csv):
id,channel,name,desc
1,product,Some product,This is an very cool product!
2,product,Other product,This is an other product!
3,faq,How to stuff,This time: Simply do it!
4,other_docs,Legal notice,All your base are belong to us!
Wanted query result (xml):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="grouped">
<lst name="channel">
<int name="matches">3</int>
<arr name="groups">
<lst>
<str name="groupValue">product</str>
<result name="doclist" numFound="2" start="0">
<doc>
<str name="name">Some product</str>
<str name="desc">This is an very cool product!</str></doc>
<doc>
<str name="name">Other product</str>
<str name="desc">This is an other product!</str></doc>
</result>
</lst>
<lst>
<str name="groupValue">faq</str>
<result name="doclist" numFound="1" start="0">
<doc>
<str name="name">How to stuff</str>
<str name="desc">This time: Simply do it!</str></doc>
</result>
</lst>
</arr>
</lst>
</lst>
</response>
How do I acceive this?
Check Field collapsing feature in SOLR
Result Grouping / Field Collapsing
I have created two cores for creating index for two different purpose.
The first core is running fine but when I try to created index with second core using DIH, it showed 5 doc created
<response>
−
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
</lst>
−
<lst name="initArgs">
−
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</lst>
<str name="command">full-import</str>
<str name="status">idle</str>
<str name="importResponse"/>
−
<lst name="statusMessages">
<str name="Total Requests made to DataSource">1</str>
<str name="Total Rows Fetched">5</str>
<str name="Total Documents Skipped">0</str>
<str name="Full Dump Started">2011-12-26 12:24:45</str>
−
<str name="">
Indexing completed. Added/Updated: 5 documents. Deleted 0 documents.
</str>
<str name="Committed">2011-12-26 12:24:45</str>
<str name="Optimized">2011-12-26 12:24:45</str>
<str name="Total Documents Processed">5</str>
<str name="Time taken ">0:0:0.52</str>
</lst>
−
<str name="WARNING">
This response format is experimental. It is likely to change in the future.
</str>
</response>
But when I try to display all results with the given below url
http://localhost:8983/solr/core1/select/?q=*:*&version=2.2&start=0&rows=10&indent=on
but it is showing 1 result only.
Any help will be appreciated...
Thanks
You probably are using multivalue=false for the field in question. If you want all 5 documents to be created you have to change this in the schema.
I need to get snippets from documents where the query terms are matched to be able to output results similar to Google's snippet beneath the website URL. For example:
Snippet - Wikipedia, the free encyclopedia
en.wikipedia.org/wiki/Snippet
A snippet is defined as a small piece of something, it may in more specific contexts refer to: Sampling (music), the use of a short phrase of a recording as an ...
I have set hl=true and even hl.fl='*' in the query URL and but no summaries are being output.
Solr FAQs say:
For a field to be summarizable it must be both stored and indexed.
I'm using Nutch and Solr and have set them up using this tutorial. What additional steps to I need to take to be able to do this?
Adding sample query and output:
http://localhost:8983/solr/select/?q=test&version=2.2&start=0&rows=10&indent=on&hl=true
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">57</int>
<lst name="params">
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">test</str>
<str name="hl">true</str>
<str name="version">2.2</str>
<str name="rows">10</str>
</lst>
</lst>
<result name="response" numFound="94" start="0">
<doc>
<arr name="anchor">
<str>User:Sir Lestaty de Lioncourt</str>
</arr>
<float name="boost">0.0</float>
<str name="digest">6c27160d0b08068f3873bb2c063508b3</str>
<str name="id">
http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt
</str>
<str name="segment">20111029223245</str>
<str name="title">User:Sir Lestaty de Lioncourt - Wikibooks</str>
<date name="tstamp">2011-10-29T21:34:27.055Z</date>
<str name="url">
http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt
</str>
</doc>
...
</result>
<lst name="highlighting">
<lst name="http://aa.wikibooks.org/wiki/User:Sir_Lestaty_de_Lioncourt"/>
<lst name="http://aa.wikipedia.org/wiki/User:PipepBot"/>
<lst name="http://aa.wikipedia.org/wiki/User:Purodha"/>
...
</lst>
</response>
Looks like you aren't specifying the field to highlight (hl.fl). You should create a text field to use for highlighting (don't use string type) and have it stored/indexed.
Even after indexing a mysql table,in solr am not able to retrieve data after querying like
http://localhost:8983/solr/select/?q=slno:5
My data-config.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/lbs"
user="user"
password="password"/>
<document name="lbs">
<entity name="radar_places"
query="select * from radar_places"
deltaImportQuery="SELECT * FROM radar_places WHERE slno='${dataimporter.delta.slno}'"
deltaQuery="SELECT slno FROM radar_places WHERE modified > '${dataimporter.last_index_time}'" >
<field column="slno" name="slno" />
<field column="place_id" name="place_id" />
<field column="name" name="name" />
<field column="geo_rss_point" name="geo_rss_point" />
<field column="url" name="url" />
<field column="location_id" name="location_id" />
<field column="time" name="time" />
</entity>
</document>
</dataConfig>
In the browser I had used
http://localhost:8983/solr/dataimport?command=full-import
Later when I checked status of command http://localhost:8983/solr/dataimport/
I got this
<response>
−
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
</lst>
−
<lst name="initArgs">
−
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</lst>
<str name="status">idle</str>
<str name="importResponse"/>
−
<lst name="statusMessages">
<str name="Total Requests made to DataSource">1</str>
<str name="Total Rows Fetched">1151</str>
<str name="Total Documents Skipped">0</str>
<str name="Full Dump Started">2010-02-21 07:53:14</str>
−
<str name="">
Indexing completed. Added/Updated: 0 documents. Deleted 0 documents.
</str>
<str name="Committed">2010-02-21 07:53:24</str>
<str name="Optimized">2010-02-21 07:53:24</str>
<str name="Total Documents Processed">0</str>
<str name="Total Documents Failed">1151</str>
<str name="Time taken ">0:0:10.56</str>
</lst>
−
<str name="WARNING">
This response format is experimental. It is likely to change in the future.
</str>
</response>
1)Is this has to do anything with <str name="Total Documents Failed">1151</str>
Am not able to figure out whats going wrong.
Are you sure that the data import configuration matches your Solr document schema?