Mailing List Archive

Doing Range/NUmber queries
Hi,

I am new to Lucene and couple of questions. I have worked with SOLR
previously, now trying to work directly with Lucene to get similar
functionality(but without SOLR). Below are my questions, thanks in advance.

1) In SOLR, there is functionality of copyfields, which dynamically copies
one field value to destination field but without actually storing it in
second time. Does Lucene provides anything directly out of the box ? If i
have to implement such feature, then i need to manually copy the value from
1 field and create new field out of it ?

2) If i have to do some Number(Integer, Double, Long) values search(Range or
simple) then how do i do that ? I looked online but examples were mentioning
RangeQuery, but i see from 6.1.0 it's not supported anymore. Can you please
post some example for that ? I found /FunctionRangeQuery/, but while
providing the second argument as long value, it started throwing error that
it expects the value as int.

3) How do i create BooleanField (while creating the document) ? And during
query, how do i create clause/query for that field ?

Really appreciate the help in advance.
Regards,



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Doing Range/NUmber queries [ In reply to ]
*Update(Found the answer for point 2).*



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4290725.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Doing Range/NUmber queries [ In reply to ]
For 1), you need to copy it yourself, i.e. add another Field to the Lucene
Document you are about to index, with the same (string, numeric, etc.)
value from the first field.

For 2), it's best to use points (IntPoint, etc.) for range filtering.

For 3), to search a boolean value, just map your boolean to a token, e.g.
"true" and "false".

Mike McCandless

http://blog.mikemccandless.com

On Mon, Aug 8, 2016 at 1:37 AM, lukes <mail2lokesh@gmail.com> wrote:

> *Update(Found the answer for point 2).*
>
>
>
> --
> View this message in context: http://lucene.472066.n3.
> nabble.com/Doing-Range-NUmber-queries-tp4290722p4290725.html
> Sent from the Lucene - General mailing list archive at Nabble.com.
>
Re: Doing Range/NUmber queries [ In reply to ]
Thanks Michael,

Is there a way to partially update the document ? I know there's a API
updateDocument on IndexWriter, but that seems to create a new document with
just a field i am specifying. What i want is delete some fields from
existing(indexed) document, and then add some new fields(could or not be
same). Alternatively i tried to search for the document, and then calling
removeFields and finally updateDocument, but now any search after the above
process is not able for find that document(I created the new IndexReader).
Am i missing anything ?

Regards.



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4291023.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Doing Range/NUmber queries [ In reply to ]
No, you must replace the entire document: the old one is removed, and the
new one is indexed in its place.

The one exception to this is update-able document value (e.g. see
IW.updateNumericDocValue).

Mike McCandless

http://blog.mikemccandless.com

On Tue, Aug 9, 2016 at 2:49 PM, lukes <mail2lokesh@gmail.com> wrote:

> Thanks Michael,
>
> Is there a way to partially update the document ? I know there's a API
> updateDocument on IndexWriter, but that seems to create a new document with
> just a field i am specifying. What i want is delete some fields from
> existing(indexed) document, and then add some new fields(could or not be
> same). Alternatively i tried to search for the document, and then calling
> removeFields and finally updateDocument, but now any search after the above
> process is not able for find that document(I created the new IndexReader).
> Am i missing anything ?
>
> Regards.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.
> nabble.com/Doing-Range-NUmber-queries-tp4290722p4291023.html
> Sent from the Lucene - General mailing list archive at Nabble.com.
>
Re: Doing Range/NUmber queries [ In reply to ]
Thanks Michael.

Regards



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4291046.html
Sent from the Lucene - General mailing list archive at Nabble.com.
Re: Doing Range/NUmber queries [ In reply to ]
Hi Michael,

Do you know, if Filtered Queries are supported in Lucene ? I tried to
find, but couldn't find anything relevant. So i have some queries which i
want to apply as filter, don't want to contribute in the scoring.Would
filter queries speed up the query process ? Can i combine filter and queries
together ? Also during indexing do i need to mention anything special for
fields that can be used in filters ?

Regards.



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4291058.html
Sent from the Lucene - General mailing list archive at Nabble.com.
RE: Doing Range/NUmber queries [ In reply to ]
Hi,

Since Lucene 6, Filters as a separate class are gone (deprecated in Lucene 5). Every query can now be used as a filter. There are 2 possibilities:

- To apply as a filter next to other scoring queries, use a BooleanQuery with filter clauses (BooleanClause.Occur.FILTER) next to the standard scoring clauses (MUST or SHOULD). The FILTER clauses are standard queries.
- To execute a single query without scoring (constant score of 1), use ConstantScoreQuery

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: lukes [mailto:mail2lokesh@gmail.com]
> Sent: Wednesday, August 10, 2016 1:44 AM
> To: general@lucene.apache.org
> Subject: Re: Doing Range/NUmber queries
>
> Hi Michael,
>
> Do you know, if Filtered Queries are supported in Lucene ? I tried to
> find, but couldn't find anything relevant. So i have some queries which i
> want to apply as filter, don't want to contribute in the scoring.Would
> filter queries speed up the query process ? Can i combine filter and queries
> together ? Also during indexing do i need to mention anything special for
> fields that can be used in filters ?
>
> Regards.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Doing-
> Range-NUmber-queries-tp4290722p4291058.html
> Sent from the Lucene - General mailing list archive at Nabble.com.
RE: Doing Range/NUmber queries [ In reply to ]
Thanks Uwe,

Quick follow up questions, would Filter query perform any better ? I hope
performance would still be same, but just out of curosity.

Regards.



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4291666.html
Sent from the Lucene - General mailing list archive at Nabble.com.
RE: Doing Range/NUmber queries [ In reply to ]
Hi,

I don't understand your question. Filter queries no longer exit since Lucene 6! If you want to filter, use any query and pass it as BooleanClause.Occur.FILTER to aBooleanQuery. Done.

Those FILTER clauses may (depending on the query type) perform better than MUST clauses, because no score is calculated.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: lukes [mailto:mail2lokesh@gmail.com]
> Sent: Saturday, August 13, 2016 11:04 PM
> To: general@lucene.apache.org
> Subject: RE: Doing Range/NUmber queries
>
> Thanks Uwe,
>
> Quick follow up questions, would Filter query perform any better ? I hope
> performance would still be same, but just out of curosity.
>
> Regards.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Doing-
> Range-NUmber-queries-tp4290722p4291666.html
> Sent from the Lucene - General mailing list archive at Nabble.com.
RE: Doing Range/NUmber queries [ In reply to ]
Thanks, that's what i wanted to confirm.

Rergards



--
View this message in context: http://lucene.472066.n3.nabble.com/Doing-Range-NUmber-queries-tp4290722p4292300.html
Sent from the Lucene - General mailing list archive at Nabble.com.