solr fq without specifying field - solr

I am getting unexplainable results doing filtered query.
when entering "searchstring" into fq w/o specifying field and got a lot of hits. The schema.xml sets the "content" field as the default search field. However, the returned results is different when I enter content:"searchstring". Rather, it is the same if I enter url:"searchstring".
How did solr get configured to use url as the default fq search field? I checked into schema.xml but can not figure out how this was set.
does any one know?

It is most likely in your solrconfig.xml as default field. Just to be sure which field the fq is searching by default in your environment, run the query with debug=true option and in the debug response you will see an entry with "parsed_filter_queries". This will provide actual field on which it is filtering.

Related

Incorrect results for Solr search with multiple terms

Perhaps someone can enlighten me on how Solr matches terms. So I have a string attribute named assignedBy, and I do a query against this attribute with the value "Aaron Mason" (no quotes). Solr returns more matches than I anticipated because the term "Mason" also matches documents whose other fields contain the word "Mason" in it. By turning on debugging feature (from Solr admin), I see Solr breaks down the query into two attribute queries - "aaron" for assignedBy and "mason" for the catch-all text (see below). Is this the correct behavior? How do I ensure that it only finds matches against the attribute I specify? Thanks.
"debug":{
"rawquerystring":"assignedBy:Aaron Mason",
"querystring":"assignedBy:Aaron Mason",
"parsedquery":"assignedBy:aaron _text_:mason",
"parsedquery_toString":"assignedBy:aaron _text_:mason",
yes you are correct. when you q=assignedBy:Aaron Mason
after parsing the query, based on you query tokenizers in schema file, it looks like
assignedBy:aaron and _text_:mason.
if you don't specify field name queryterm is searched in default field (which is set in solrconfig.xml file) you can look for <str name="df">text</str> under /select handler. in your case it might be _text_.
So, Solr search for its index and retrieve combined results of all documents which has field assignedBy with term "Aaron" and all documents which has field _text_ with term "mason".
you might have used copyfield to copy some field values to text field. check for it.
You can use dismax/edismax where you can specify in which field all your terms to search for
example:
q=Aaron Mason&wt=json&debugQuery=on&defType=dismax&qf=assignedBy
This only finds matches against the field "assignedBy" specified in qf

/select with 'q' parameter does not work

Whenever i query with q=: it shows all the documents but when i query with q=programmer 0 docs found.(contents is the default search field)
my schema has: id(unique),author,title,contents fields
Also query works fine for:
q=author:"Value" or q=title:"my book" etc, only for contents field no results.
Also when i query using spell checker(/spell?q=programmer) output shows spelling suggestions for this word,when 'programmer' is the right word and present in many documents.
I referred the example docs for configurations.
All of a sudden i am getting this,initially it worked fine.
I guess there some problem only in the contents field,but cannot figure it out.
Is it because indexes are not created properly for contents field?
(I am using solr 4.2 on Windows 7 with tomcat as webserver)
Please help.Thanks a lot in advance.
Are you sure you set the default search field? The reason you have this problem might be because you didn't set the <defaultSearchField> field in your schema.xml file. This is why "q=author:value" works while q=WHATEVER doesn't.
The Is used by Solr when parsing queries to
identify which field name should be searched in queries where an
explicit field name has not been used.
But also consider this:
The is used by Solr when parsing queries to
identify which field name should be searched in queries where an
explicit field name has not been used. It is preferable to not use or
rely on this setting; instead the request handler or query LocalParams
for a search should specify the default field(s) to search on. This
setting here can be omitted and it is being considered for
deprecation.
Do you have any data in your instance. try q=*:* and see what it returns. "for" is a stop word, may be it was filtered out. Look for something else as value to test.

Solr query syntax facet issues

I have a solr server setup and am attempting to get facets working correctly, the following query
/select?q=*:*&wt=xml&indent=true?&facet=true&facet.field=style&facet.field=variety&facet.field=packsize&fq=packsize:6&fq=CABERNET
Where there are three facet fields "style, variety and packsize". The query above returns a number of correct results however when I execute this
/select?q=*:*&wt=xml&indent=true?&facet=true&facet.field=style&facet.field=variety&facet.field=packsize&fq=packsize:6&fq=variety:CABERNET
Suddenly I receive zero results why does prefixing "variety" to the fq break for this but not for packsize?
Also when trying to add &fq=style:red or &fq=red neither of these work even though there are many results with "style = red". Any ideas??
For the filter queries if the field is not specified, the query would work on the default field.
You can check the filter query executed by adding debugQuery=on
<arr name="parsed_filter_queries">
<str>text:solr100</str>
</arr>
So check for the default field should have the CABERNET term.
Also the match would depend upon the field type, the analysis performed and where the field is indexed or not.
Only fields indexed would be able to filter the results.

solr query not returning results

When I enter search url
http://localhost:8983/solr/select?qt=standard&rows=10&q=*:*
I get a response with 10 documents.
But when I want to test specific query, then nothing comes up. For example:
http://localhost:8983/solr/select?qt=standard&rows=10&q=white
Why is that happening? I clearly see in results, that there is document with word "White" in it. So Why solr dont return that document as result.?
q=*:* searches for all content on all the documents, hence you get back the results.
q=white will search for white on the default search field, which is usually text if you have not modified the schema.xml.
<defaultSearchField>text</defaultSearchField>
You can change the default field to be the field you want to search on.
OR use specific field to search on the specific field e.g. title q=title:white
If you want to search on multiple field, you can combine the fields into one field by using copyfields or use dismax request handler.

Solr only search in default field

I can't search in other field than the default. With q=field:search doesn't return nothing (but documents exists obsviouly). Also didn't find it with defType=dismax.
In the schema.xml I have the field with indexed="true" and stored="true" just like the default one.
What I am missing ?
Thanks in advance.
So you are issuing a GET?
Have you checked your encoding the ':', as it should be %3A.
Without the right encoding you maybe trying to search the default field for 'field:search'.
Can you test your query in /solr/admin ?
just checking, if you changed your schema, you need to delete the data in /var/data and restart solr, otherwise you may be searching old not indexed stuff.
If you are using a DisMax search make sure that you have the fields you are searching added to the query fields parameter solr search. It might just be that you are declaring a qf parameter in your search statement and your field is missing from the list.
This may be a bit too plain, but did you - besides restarting your solr instance - remember reindex? Otherwise changes in the schema.xml won't apply.

Resources