Field grouping in SolrNet? - solr

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.

Related

solr: Using MLT with edismax, is there a way to fetch interesting terms then pass then to edismax regular query?

Wanted to enrich morelikethis generated interestingTerms query adding some custom field:value^boost to it.
My current solution is:
- run a mlt query seeting interestingTerms=details
- building a query from interesting terms (term^score term2^score2...)
- append edismax main query with interesting terms query.
Is there a better solution (maybe even in a single query call?)
EDIT: I also need to use bf (boosting functions)
The /tvrh handler (the termVector query) does that
You can find my implementation in this Clojure Solr wrapper named Corona.
In https://github.com/Stylitics/corona/blob/master/src/corona/query.clj#L187
look at query-term-vectors and at query-mlt-tv-edismax which uses it.
Another possibility would be to use the {!mlt ...} query parser. Docs can be found here https://lucene.apache.org/solr/guide/7_7/other-parsers.html#more-like-this-query-parser

Synonyms in Solr Query Results

Whenever I query a string in solr, i want to get the synonyms of field value if there exists any as a part of query result, is it possible to do that in solr
There is no direct way to fetch the synonyms used in the search results. You can get close by looking at how Solr parsed your query via the debugQuery=true parameter and looking at the parsedQuery value in the response but it would not be straightforward. For example, if you search for "tv" on a text field that uses synonyms you will get something like this:
$ curl "localhost:8983/solr/your-core/select?q=tv&debugQuery=true"
{
...
"parsedquery":"SynonymQuery(Synonym(_text_:television _text_:televisions _text_:tv _text_:tvs))",
...
Another approach would be to load in your application the synonyms.txt file that Solr uses and do the mapping yourself. Again, not straightforward,

Lucene OR query not working

I am trying to query Solr with following requirement:
_ I would like to get all documents which not have a particular field
-exclusivity:[* TO *]
I would like to get all document which have this field and got the specific value
exclusivity:(None)
so when I am trying to query Solr 4 with:
fq=(-exclusivity:[* TO *]) OR exclusivity:(None)
I have only got results if the field exists in document and the value is None but results not contain results from first query !!
I cannot understand why it is not working
To explain your results, the query (-exclusivity:[* TO *]) will always get no results, because you haven't specified any result to retrieve. By default, Lucene doesn't retrieve any results, unless you tell it to get them. exclusivity:(None) isn't a limitation placed on the full result set, it is the key used to find the documents to retrieve. This differs from a database, which by default returns all records in a table, and allows you to limit the set.
(-exclusivity:[* TO *]) only specifies what NOT to get, but doesn't tell it to GET anything at all.
Solr has logic to handle Pure negative queries (I believe, in much the same way as below, by implicitly retrieving all documents first), but from what I gather, only as the top level query, and it does not handle queries like term1 OR -term2 documented here.
I believe with solr you should be able to use the query *:* to get all docs (though that would not be available in raw lucene), so you could use the query:
(*:* -exclusivity:[* TO *]) exclusivity:(None)
which would mean, get (all docs except those with a value in exclusivity) or docs where exclusivity = "None"
I have founded answer to this problem. I have made bad assumption how "-" works in solr.I though that
-exclusivity:[* TO *]
add everything without exclusivity field to the data set but it is not the case. The '-' could only exclude things from data set. BTW femtoRgon you are right but I am using it as fq (filter query) not as a master query I have forgotten to mention that.
So the solution is like
-exclusivity:([* TO *] AND -(None))
and full query looks like
/?q=*:*&fq=-exclusivity:([* TO *] AND -(None))
so that means I will get everything does not have field exclusivity or has this field and it is populated with value None.

Get facet results only in Solr

I am trying to make search on my database using Solr, and i need to build a facet for the date of the articles(2011-6-12,2011-7-1 ..etc) and another facet for category(sport, news..etc) i built my php code using apache_solr_service and every thing is fine till now, i can do search for my data in the database, but i want to use facet to filter the articles that are created in specific date or to get the articles that belong to a specific category,
i used:
http://localhost:8888/solr/collection1/select?facet=true&facet.query=datecreated:2011-6-21&facet.mincount=1&wt=json&json.nl=map&q=ruba&start=0&rows=10
its returned all the articles that have 'ruba' word and give me the count of articles that have been created in 2011-6-21.
what i need is to get only the articles that have ruba word AND are created on 2011-6-21, i want only facet results to be returned
Try using filter query, fq=datecreated:2011-6-21 instead of facet

Limiting the output from MoreLikeThis in Solr

I'm trying to use MoreLikeThis to get all similar documents but not documents with a specific contenttype.
So the first query needs to find the one document that I want to get "More Like This" of - and the second query needs to limit the similar documents to not be pdf's (-contenttype:pdf)
Does anyone know if this is possible?
Thanks
When using the MoreLikeThisHandler, all the common parameters applied to the mlt results set. So you can use the fq parameter to exclude your pdf documents from the mlt results:
http://localhost:8983/solr/mlt?q=test&mlt.fl=text&fq=-contenttype:pdf
The q parameter allows to select the document to generate mlt results (actually, it's the first document matching the initial query that is used).

Resources