Suppose that my index has 3 fields: title, x and y.
I know one range(10 < x < 100) can query like this:
http://localhost:8983/solr/select?q=x:[10 TO 100]&fl=title
If I want to two range(10 < x <100 AND 20 < y < 300) query like
SQL(select title where x>10 and x < 100 and y > 20 and y < 300)
by using Solr range query or SolrJ, but I don't know how to implement this. Does anybody else know? Thanks
Email: enzhaohoo#gmail.com
Take a look at the docs for SolrJ. Successive calls to addFilterQuery will continue to build up your query. Alternatively you can have two things in one fq:
http://localhost:8983/solr/select?q=&fq=x:[10+TO+100]+AND+y:[20+TO+300]&fl=title
There is a method in class SolrQuery can solve your problem,
setFilterQueries(String... fq)
You can take a look at this.
Related
So I have this formula, and it's working as intended but I would like to further refine the data.
Formula:
=QUERY('Users'!A1:Q, "Select A,B,C,F,G,O,Q where Q >= 180 and Q < 44223")
I have tried:
=QUERY('Users'!A1:Q, "Select A,B,C,F,G,O,Q where Q >= 180 and Q < 44223 and F not like '*text*'")
But that caused an error. Ideally, I would like to ommet any results that match partial texts in columns C and F. Any ideas?
EDIT:
Included a link to an example sheet
Ideally, I want the query to match everything in column F except 'Archived' (but needs to be wildcarded) and everything in column C except Delta (again, needs to be wildcarded)
try:
=QUERY(Sheet1!A1:Q6,
"select A,B,C,F,G,O,Q
where Q >= 180
and Q < 44223
and not lower(O) matches '.*archived.*'
and not lower(C) matches '.*delta.*'")
Comparing dates is of course easy using Solr, but I need to do find a Solr function, where I can do the following:
int value = date2 - date1;
if (value < 0)
do something...
if (value > 0)
do something else...
I know about for example if(exists(myField) ,100, 0), but instead of exists() I want to say if(((date2-date1) < 0), 100, 0).
Is there a way or a function to do this kind of comparison?
What is the difference between these queries:
With consequent filters:
qry1 = Account.query() # Retrieve all Account entitites
qry2 = qry1.filter(Account.userid >= 40) # Filter on userid >= 40
qry3 = qry2.filter(Account.userid < 50) # Filter on userid < 50 as well
Using ndb.OR:
qry = Article.query(ndb.OR(Account.userid >= 40,
Account.userid < 50))
Using ndb.AND:
qry = Article.query(ndb.AND(Account.userid >= 40,
Account.userid < 50))
The first query does an AND. Thus, only the entities that match both inequalities will be returned by the query. The second query does an OR. Thus, entities that match either of the filters will be returned. For more information about ndb queries, take a look at NDB Queries.
Third and the First query are exactly identical. But the second query is absurd, it may end up returning all Entities in the Kind.
Solr FunctionQuery has a DIV(x,y) function. I have such a need if y=0, then y should be equal to x.
In other words, I need to represent the following logic with FunctionQuery:
if y == 0, return 1 /* i.e. DIV(x,x) */
else, return DIV(x,y)
Somehow, from the Solr doc, I cannot find any comparison function, e.g. EQ(x, value), etc. for me to use.
Will anyone be able to give me a hint to construct my desired logic using FunctionQuery?
Thanks!
To clean up this question and log what is my final solution, thanks to Srikanth Venugopalan comment:
actually you need to switch the arguments. exposure_count = 0 is interpreted as false. So your condition would be {!boost b=if(exposure_count,div(1,exposure_count),1)}"
As it seems, Lucid works documentation does have a mistake. The FunctionQuery parser does not take comparison operators such as ==, at least this is what I found by looking into the sourcecode. Also, the field separator for IF() function should be ,(comma) and not ;(semi-colon).
The official Solr wiki is correct.
For string terms this works:
if(termfreq(fieldname,"value"),2,1)
which yields 2 if "value" is contained in "fieldname" (termfreq will be >0)
you can use == for equals and if conditional statement as below :-
e.g. if(y == 0; 1; DIV(x,y))
Check for the example # Documentation
if(color=="red"; 100; if(color=="green"; 50; 25)) :
This function checks the document field "color", and if it is "red" returns 100, if it is "green" returns 50, else returns 25.
Edit :-
Solr if wiki mentions , (comma) as seperator
e.g. if(exists(myField),100,0)
When I perform a simple query like this:
select * from nodeType
Calling skip(N) on the range iterator is slow.
What am I doing wrong?
Found out why (self answering) - was using document order by default.
Try adding a sensible "order by" to the query - goes from minutes for 10000 nodes to < 1 second.
Sadly, the RangeIterator skip() method in Jackrabbit implementation (RangeIterator is just an interface) is traversing over the nodes linearly. You might as well just write
int counter = 0;
while ( counter < offset && iter.hasNext() ) { iter.next(); counter++; }