Reputation: 175
I'm trying to implement search over all fields on Solr. Exhttp://localhost:8983/solr/sample-items/select?q=oscar
but no result returns. However, If I specify the field it works fine Ex http://localhost:8983/solr/sample-items/select?q=name:oscar
I try to use copyField like following but not working: on managed-schema file
<field name="Designation" type="text_general" stored="true"/>
<field name="Location" type="text_general" stored="true"/>
<field name="_root_" type="string" docValues="false" indexed="true" stored="true"/>
<field name="_version_" type="plong" indexed="false" stored="true"/>
<field name="age" type="plongs" stored="true"/>
<field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="name" type="text_general" stored="true"/>
<field
name="_text_"
type="text_general"
indexed="true"
stored="true"
multiValued="true"
/>
.
.
.
<fields>
<copyField source="Designation" dest="_text_" maxChars="256"/>
<copyField source="name" dest="_text_" maxChars="256"/>
<copyField source="Location" dest="_text_" maxChars="256"/>
</fields>
on solrconfig.xml file
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
</lst>
<initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse">
<lst name="defaults">
<str name="df">_text_</str>
</lst>
</initParams>
Any advice?
Upvotes: 0
Views: 262
Reputation: 8678
You can also think of using the edismax query parser. Here the link for the same. the edismax
query parser .Here you can provide the qf
parameter. It provides you to boost hits in each field differently. For example qf=field1^4 field2
will give hits in the field1
field four times more weight than hits in the field2
field.
Search across multiple fields, specifying (via boosts) how important each field is relative each other:
http://localhost:8983/solr/techproducts/select?q=video&defType=edismax&qf=features^20.0+text^0.3
You can boost results that have a field that matches a specific value:
http://localhost:8983/solr/techproducts/select?q=video&defType=edismax&qf=features^20.0+text^0.3&bq=cat:electronics^5.0
Upvotes: 0
Reputation: 2264
To be able to search from >1 fields (or over all fields) by default , you need to perform following two configurations.
managed_schema
) create copy field and copy other field's data into this copy field. Example is as follows....
<field name="_text_" type="text_general" multiValued="true" indexed="true" stored="false"/>
...
<copyField source="directed_by" dest="_text_" maxChars="256"/>
<copyField source="genre" dest="_text_" maxChars="256"/>
...
solrconfig.xml
, update initiParam
tag to make above created copy field as default search field for search handlers. Example is as follows.<initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse">
<lst name="defaults">
<str name="df">_text_</str>
</lst>
</initParams>
Sample Query and output :
ShubhangiP:~ spardeshi$ curl -XGET http://localhost:8983/solr/films/select?q=Gary
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"Gary"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"/en/45_2006",
"directed_by":["Gary Lennon"],
"initial_release_date":"2006-11-30T00:00:00Z",
"genre":["Black comedy",
"Thriller",
"Psychological thriller",
"Indie film",
"Action Film",
"Crime Thriller",
"Crime Fiction",
"Drama"],
"name":".45",
"_version_":1645282402834055168}]
}}
From details provided in question, in managed_schema
file collector field is used as copy field for three other fields named Designation , Name and Location.
But not sure if you made collector field as default search field.
Upvotes: 1