hi guys i have started working on a project which need solr implemtation for searching.
I am using SolrNet Lib and my question is:
I have two field in solr index Maxsal and Minsal and i have Currentsal parameter which contains salary amount. What i want is, get all records which satisfy this condition:
currentsal< Maxsal && currentsal> Minsal
Take a look at Solr range query. It should allow to create query like this
minsal:[* TO PARAM] AND maxsal:[PARAM TO *]
For more information look here - http://www.solrtutorial.com/solr-query-syntax.html
Never noticed that Query() take string parameter too.
So,
Solr.Query("MaxSal<="+parameter && MinSal>=parameter")
Related
I have indexed few documents and now while trying to query a string from solr admin console, I am able to retrieve score value for each result retrieved by selecting field as score. But I would need to check the doc score, termfreq and other parameters considered for calculating this score which can help me to debug and understand. Can anyone help me with the possible ways? Are there any certain keywords or fields or query parameters to be specified while querying from solr admin console? Solr Version that I am using is 7.6.0.
Add debug=all (the new version of debugQuery=true) to your query string. It'll include a detailed explanation of how each part of your query contributes to the score.
All:
[UPDATE] Thanks for Andrea's answer, currently I am using this way:
If you send also a facet.mincount=1 then the start bound is just an
indication because Solr will return only those values (i.e. ranges)
that have at least 1 document inside. So for instance you could
indicate a very low value as start.
Note: This is only proved works for my case, so use your judgement
&facet=true&facet.range=createDate&facet.range.gap=%2B2DAY&facet.range.end=NOW&facet.range.start=NOW-1000DAY&facet.mincount=1
I am pretty new to Solr facet. Suppose that I have some documents which has createDate:
"2015-03-23T17:59:00Z",
"2015-03-23T22:13:00Z",
"2015-03-17T20:48:00Z",
"2015-03-19T17:43:00Z",
"2015-03-19T21:58:00Z",
"2015-03-16T19:13:00Z",
"2015-03-16T22:26:00Z",
"2015-03-13T21:33:00Z",
"2015-03-13T21:39:00Z",
"2015-03-13T23:27:00Z",
"2015-03-16T16:46:00Z",
"2015-03-18T17:44:00Z",
"2015-03-18T18:10:00Z",
"2015-03-18T18:11:00Z"
.......
My questions are :
[1] How to get the result range by DAY?
[2] How to get facet result grouped by WEEK( or let us say 7 days)?
Thanks
It is called range faceting. I suggest you to read the Solr wiki but in the meantime:
facet.range=(field name)
facet.range.start=(start date or value)
facet.range.end=(end date or value)
facet.range.gap=(interval value or expression)
In your case you should use +1DAY or +7DAYS as facet.range.gap.
There are also other parmeters so it's better if you have a look at the wiki
I have Solr documents that can have 3 possible states (state_s in {new, updated, lost}). These documents have a field named ip_s. These documents also have a field nlink_i that can be equal to 0.
What I want to know is: how many new ip_s I have. Where I consider a new ip is an ip that belong to a document whose state_s="new" that does not appear in any document with state_s = "updated" OR state_s = "lost" .
Using Solr facet search I found a solution using the following query parameters:
q=sate_s:"lost"+OR+sate_s:"updated"
facet=true&facet.field=ip_s&facet.limit=-1
Basically, all ip in
"facet_fields":{
"ip_s":[
"105.25.12.114",1,
"105.25.15.114",1,
"114.28.65.76",0,
...]
with 0 occurence (e.g. 114.28.65.76) are "new ips".
Q1: Is there a better way to do this search. Because using the facet query describe above I still need to read the list of ip_s and count all ip with occurence = 0.
Q2: If I want to do the same search, (i.e. get the new ip) but I want to consider only documents where nlink_i>0 how can I do?. If I add a filter : fq=nlink_i:[1 TO *] all ip appearing in documents with link_i=0 will also have their number of occurrence set to 0. So I cannot not apply the solution describe above to get new ip.
Q1: To avoid the 0 count facets, you can use facet.mincount=1.
Q2: I think the solution above should also answer Q2?
Alternatively to facets you can use Solr grouping functionality. The aggregation of values for your Q1 does not get much nicer, but at least Q2 works as well. It would look something like:
select?q=*:*&group=true&group.field=ip_s&group.sort=state_s asc&group.limit=1
In order for your programmatic aggregation logic to work, you would have to change your state_s value for new entries to something that appears first for ascending ordering. Then you would count all groups that contain a document with a "new-state-document" as first entry. The same logic still works if you add a fq parameter to address Q2.
I found another solution using facet.pivot that works for Q1 and Q2:
http://localhost:8983/solr/collection1/query?q=nbLink_i:[1%20TO%20*]&updated&facet=true&facet.pivot=ip_s,state_s&facet.limit=-1&rows=0
With Solr I can sort results by field and start at a particular result number; however, I would like to start at a particular field value instead (or in addition to). For example, I have a library of books that I want to sort by title and start at the H's. In SQL it would look something like this:
SELECT *
FROM Books
WHERE title >= 'H'
ORDER BY title
LIMIT 10
Can this be done in Solr? I want to be able to do this in Solr and not a separate database because I already use Solr for my search engine and I want to take advantage of features like facets.
I'm using Solr 4.7.0, but I am able to upgrade to newer versions.
Did you try filter query with range title:[H* to Z*]?
Let me know if you need more info or exact query.
I have a standard Solr 3.6 index and am looking to get the latest N documents back (date ascending from indexing them).
This site was helpful but not exactly what I'm looking for.
I am looking to do something like this:
localhost:8080/solr/select/?q=greekbailout&wt=json; date asc
Basically, query whatever with json output and the latest N submitted documents to the index. Anybody run into this before?
Use &sort=date asc for pure sorting and this for boosting newer documents.
solr query using date field with N documents returned in results
localhost:8080/solr/select/?q=greekbailout&wt=json&sort=date asc&rows=N
default schema of solr has a field called timestamp, which stores time at which a particular document is created or modified, so if your date field doesn't quite store this and this is your requirement, you can use timestamp.. just replace date with timestamp
In your Solr URL just apend &sort=<field>+<asc/desc>. Also your field should be indexed and not multivalued.
You can also sort on multiple fields.
&sort=<field name>+<direction>[,<field name>+<direction>]...
http://wiki.apache.org/solr/CommonQueryParameters#sort