SOLR AND clause in q object - solr

I need to query SOLR index using a WHERE clause -
When I try with AND clause its not working
NOT WORKING
category:2 AND -document_type:category
WORKING
category:2 -document_type:category
Which is the correct syntax?

You could try to pass -(document_type:category) as a filter query (fq=-(document_type:category)). Should work that way and is also faster because of optimized caches on filter queries.
Also tested your specific case, but it also works for me in a regular query.

Related

Solr: Subquery concept

http://xx.xx.xx.xx:8983/solr/collection1/select?q=_query_:{! v=cars rows=10 df=content_urdu fl=score,*}&wt=json&indent=true&rows=30&sort=pr desc
Please someone can explain me, what the above query will do to clear my concepts? Is the text inside curly brackets is sub-query? How will it execute?
query will give you the flexibility of using different query parcers instead of the ones that is by default selected by your query handler in your mentioned example select handler.
Everything inside the braces are your parameters for the Qparser and anything outside is the q parameter for the parser but should be within the quotes. In the below example edismax and surround parser are working together with AND in between them. So they act as a filter. Its the same as using them in fq fields but this helps when generating dynamic queries where there can be OR instead of AND. This feature leverages solr and lucene's multiple Qparsers and can be used together with faceting to get desired results.
_query_:"{!edismax rows=10 df=content_urdu } source_type:\"custom\"" AND
_query_:"{!surround maxBasicQueries=10000} content:5N(tru*,(equi* OR and*))

Difference between q and fq in Solr

Someone please give me a decent explanation of the difference between q and fq in Solr query, covering some points such as -
Do they have the same syntax?
Do they return same results?
When to use which one and why?
Any other differences
Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter.
The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).
The q parameter takes your query and execute against the index. Then you can use filter queries (can use multiple filter queries) to filter the results.
For example your query can look like this.
q=author:shakespeare
this will match the documents which has 'shakespeare' in the 'author' field. Then you can use filter queries like this.
fq=title:hamlet
fq=type:play
Those will filter the results based on the other fields. You can even filter on the same field.
The query syntax is similar for both q and fq parameters

Solrnet - Boost query with function

I am trying to query sol using solrnet.
I am looking to boost the query by a record's property.
My query then looks like this:
/select?fl=QualityScore,score&q={!boost+b=sum(1,log(sum(1,QualityScore)))+v=$qq}&qq="qome query"
Is there a way to do this using SolrNet?
PS - I already looked at SolrNet queries with boost functions and I dont see the same result when I use 'bf'.
Mauricio's pointer is what helped me in this case.
Local Params

Multiple Filter Queries with OR operation in Solr

I need to define multiple Filter Queries in my query but with OR operation.
Imagine that there are fq1, fq2 and fq3. Now I would like my final filter query to be :
fq=fq1 AND fq2 OR fq3
Is there any way to handle it in Solr?
It seems that now SOLR (>4.5) supports these type of queries, i.e.
fq=(field1:value1 OR field2:value2)
This is not possible in Solr. It would be great if you could define your filter queries and then separately specify the boolean logic that should be applied between them.
A few years ago I created a Jira issue hoping to see this get added.
You can do something like this:
fq=fieldA:(valueA OR valueB) OR fieldB:valueC
+fq:fq1 +(fq2:fq2 fq3:fq3) <-- if default query filter type is OR

Field grouping in SolrNet?

I am trying to make a query in solr.net that generates a solr query with a filter query with more than one term in it e.g.: fq=Size:(4 large)
However, when I pass ?f_Size=(4 large) in the query string to the SolrNet sample app (found here: http://code.google.com/p/solrnet/downloads/list), no results are found.
Looking at the logs, I can see that the filter query generated is fq=Size:"\(4+large\)" so it makes sense that no results are found.
Is there a way in SolrNet to generate a filter query with more than one term?
Where the filter queries are built, try replacing Query.Field(...).Is(...) with Query.Simple(...) (you have to build the query yourself). See the wiki for reference.

Resources