1

I am using Solr version 5 for searching data. I am using below query which searches for keyword in all fields.

http://localhost:8983/solr/document/select?q=keyword1+keyword2&wt=json

Can anyone suggest me query to search for keyword only in title field.

Thanks.

Kalpesh
  • 83
  • 2
  • 6

3 Answers3

5

use

   http://localhost:8983/solr/document/select?q=title:*yourkeyword*&wt=json

or for exact match

   http://localhost:8983/solr/document/select?q=title:"yourkeyword"&wt=json
Azat Nugusbayev
  • 1,391
  • 11
  • 19
  • I am having multiple keywords which are separated by space like `keyword1 keyword2`. How I will search that? – Kalpesh Dec 26 '15 at 10:16
  • 2
    sth like `q=title:"keyword1" OR title:"keyword2"` – Azat Nugusbayev Dec 26 '15 at 10:47
  • I can get it working with `select?q=title:keyword1 keyword2&wt=json` but its not showing results with highest matched keywords first. Instead when I use `select?q=keyword1 keyword2&wt=json` it shows results in perfect order. Thanks. – Kalpesh Dec 26 '15 at 20:46
1

You can not search for a keyword in all fields without some extra work:

How can I search all field in SOLR that contain the keywords,.?

The "q"-Parameter contains the query string and for the standard parser this means that you must specify the field via colon like in

fieldname:searchterm

or the standard parser will use the default field. The default field is specified in the "df"-Parameter and if you did not change your solrconfig.xml you will search in the "text"-Field because you will find something like

<requestHandler name="/select" class="solr.SearchHandler">
  <lst name="defaults">
    <str name="df">text</str>
  </lst>
</requestHandler>

P.S. If you want to search in all fields you have either to copy all field-content to one field or you must use a specific query parser like dismax parser, where you can list all your fields in the "qf"-Parameter.

P.P.S. You can not search in all fields but you can highlight in all fields :-)

Community
  • 1
  • 1
Karsten R.
  • 1,628
  • 12
  • 14
0

The best way is to run the query from Admin concole. When we run it, it also provides the actuall SQL query executed. Just copy the query and use it.

About the question: search specific field value from the Solr. In the admin console look for 'Q' text box. write the yourfield=value OR yourfield:value. Hit the 'Execute Query' button. Top right side the SQL will be available.

Generated Query: ......select?indent=on&q=YOURFIELD:"VALUE"&wt=json

Sonu
  • 712
  • 9
  • 7