I can only get Solr to work when I include a field in the query, for example:
http://localhost:8983/solr/collection1/select?q=lastname:johnson
The above query returns approximately 18 results.
Shouldn't it be possible to use Solr (/Lucene) without specifying the field? Such as:
http://localhost:8983/solr/collection1/select?q=johnson
I also tried adding the fields list:
http://localhost:8983/solr/collection1/select?q=johnson&fl=cus_id%2Cinitials%2Clastname%2Cpostcode%2Ccity
But all these queries return zero results.
These are the fields from my schema.xml:
<field name="cus_id" type="string" indexed="true" stored="true"/>
<field name="initials" type="text_general" indexed="true" stored="true" />
<field name="lastname" type="text_general" indexed="true" stored="true"/>
<field name="postcode" type="string" indexed="true" stored="true" />
<field name="city" type="text_general" indexed="true" stored="true"/>
I don't know what else to try. Any suggestions?
For Solr if not field is specified the search happens on the default field (df
).
So when you search q=johnson and debug the query you will find it searching on the default field which is usually the field text
.
You can copyfield all the fields to the single field text and have it as the default field (if not default already), so that all your search queries would be searched across the default field.
Also, fl
lists the fields that would be returned as part of the result and is not related to the fields on which the search is performed.
With dismax, You can check the qf
param to specify multiple fields with variable boosts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With