Search with multiple parameters in solr - solr

Currently I having the query like this
q=mysearchparameters
It is working fine, and I think it will search for this keyword in all the fields, now I want to retrieve data only based in some specific field like this
q=name:'somename'+specialization:'somespecialization'
is it possible to query like, here I getting some unexpected datas for my second query.

You can have multiple queries, ANDed together, like this:
q=name:somename AND specialization:somespecialization
or ORer together like this:
q=name:somename OR specialization:somespecialization
Or you can use filter queries to AND them together:
q=*:*&fq=name:somename&fq=specialization:somespecialization
I won't get into queries versus filter queries as it is covered better elsewhere:
SOLR filter-query vs main-query

in order to perform a multicriteria request, you'd better do :
q=*:*
fq= name:*somename*
fq= specialization:*specializstr*
http req example : http://localhost:8983/solr/datav6/select?q=*%3A*&fq=data%3A*carlos*%5E5&fq=entity%3Aemployee&wt=json&indent=true
it' saffer on the results, faster on execution and consumes less ram.
enjoy and give me some feedback please! :)

Related

How to add conditionals or filters to a solr terms query for autosuggest

I've implemented a solr terms query for an auto suggest component.
This is how a regular query looks like:
https://myserver.com/solr/mydata/terms?omitHeader=true&wt=json&json.nl=flat&terms=true&terms.regex=.%2my search term%2A&terms.limit=20&terms.fl=location&terms.fl=price&terms.fl=state&terms.fl=city&terms.fl=country&terms.fl=id&terms.regex.flag=case_insensitive
Now my client would like to filter the results based on different criteria like location=XXX or product-price > xxx. So far I cant find a way to achieve it.
Any suggestion?
Thanks

Solr query without computing score

Is it possible to run dismax query without computing score? I just need this to make some tests - what is influence of score computing in Solr searching performance.
For now i have dismax query like this:
{
limit : 10,
params:{
defType:"dismax",
q:"${query}",
q.op:"${operator}",
qf:"${fields}",
indent:"off"
}
}
Is there some easy way to achieve what i want? Maybe i should use filter query but how can i specify operators and use query phase from user as it is without any processing in fq?
You can introduce different query parser through localparams, so something like:
q=*:*&fq={!type=dismax qf='${fields}'}${query}
.. should work. If these are not local variables that you expand yourself, the syntax might be slightly different.

Solr dismax Query Over Multiple Fields

I am trying to do a solr dismax query over multiple fields, and am a little confused with the syntax.
My core contains a whole load of podcast episodes. The fields in the index are EPISODE_ID, EPISODE_TITLE, EPISODE_DESC, and EPISODE_KEYWORDS.
Now, when I do a query I would like to search for the query term in the EPISODE_TITLE, EPISODE_DESC, and EPISODE_KEYWORDS fields, with different boosts for the different fields.
So when I search for 'jedi', the query I've built looks like this:
http://localhost:8983/solr/episode_core/select?
&defType=dismax&q=jedi&fl=EPISODE_ID,EPISODE_TITLE,EPISODE_DESC,EPISODE_KEYWORDS
&qf=EPISODE_TITLE^3.0+EPISODE_DESC^2.0+EPISODE_KEYWORDS
However, this doesn't seem to work - it returns zero records.
When I put a default field like below, it now works, but this is kind of crap because it means I'm not getting results from searching all of the 3 fields:
http://localhost:8983/solr/episode_core/select?&df=EPISODE_DESC
&defType=dismax&q=jedi&fl=EPISODE_ID,EPISODE_TITLE,EPISODE_DESC,EPISODE_KEYWORDS
&qf=EPISODE_TITLE^3.0+EPISODE_DESC^2.0+EPISODE_KEYWORDS
Is there something I am missing here? I thought that you could search over multiple fields, and I thought that the 'qf' parameter would mean you didn't need to supply the default field parameter?
All help much appreciated...
Your idea is correct. If you've defined qf (query fields) for Dismax, there shouldn't be any need to specify a df (default field).
Can you be more specific about what isn't working?
Also, read up on Configuration Invariants in solrconfig.xml as it is possible your configuration could be sending some different parameters than you've specified in the URL.
(E.g. if you're seeing a specific error message asking you to provide a df)

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