You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Alexander Kozitsin <as...@gmail.com> on 2016/10/10 10:43:18 UTC
Array as Lucene Field
Hi everyone!
I've faced a problem and had no idea how to resolve it.
So, I've got a directory with documents.
Each document might contain array of doubles. However, Lucene does not
support arrays.
What I need is to have an ability to sort documents by this field, search
values (with support of basic operations: >,>=, <, <=, =).
I know, I can create several documents for each value, but then I will have
an issue with retrieving part of data by ranges (e.g.: I need documents
from 10 to 20). There will be duplicates and incorrect ranges.
Thanks in advacne for your help!
Alexander
RE: Array as Lucene Field
Posted by ASKozitsin <as...@gmail.com>.
Oh, my fault!
Thanks, Uwe!
Alexander
--
View this message in context: http://lucene.472066.n3.nabble.com/Array-as-Lucene-Field-tp4300445p4300597.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Array as Lucene Field
Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,
Why is this a problem? Maybe you misunderstood. You can add several NumericField instances with same name! Something like:
for (double d : array) {
document.add(new DoubleField("myfield", d, Field.Store.YES/NO));
}
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: ASKozitsin [mailto:askozitsin@gmail.com]
> Sent: Monday, October 10, 2016 1:48 PM
> To: java-user@lucene.apache.org
> Subject: RE: Array as Lucene Field
>
> Thanks for quick response!
>
> Several NumericFields is a bit complicated, because I do not know how many
> values might be in array.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Array-as-
> Lucene-Field-tp4300445p4300451.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Array as Lucene Field
Posted by ASKozitsin <as...@gmail.com>.
Thanks for quick response!
Several NumericFields is a bit complicated, because I do not know how many
values might be in array.
--
View this message in context: http://lucene.472066.n3.nabble.com/Array-as-Lucene-Field-tp4300445p4300451.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Array as Lucene Field
Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,
I forgot to mention: Sorting is not possible (at least not in a consistent way), but queries will work.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Monday, October 10, 2016 1:28 PM
> To: java-user@lucene.apache.org
> Subject: RE: Array as Lucene Field
>
> Hi,
>
> You can add multiple values as NumericFields (Lucene 5.x) or PointValues
> (Lucene 6+). Just create a separate field instance and all all of them. The
> same applies for all field types.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Alexander Kozitsin [mailto:askozitsin@gmail.com]
> > Sent: Monday, October 10, 2016 12:43 PM
> > To: java-user@lucene.apache.org
> > Subject: Array as Lucene Field
> >
> > Hi everyone!
> >
> > I've faced a problem and had no idea how to resolve it.
> >
> > So, I've got a directory with documents.
> > Each document might contain array of doubles. However, Lucene does not
> > support arrays.
> > What I need is to have an ability to sort documents by this field, search
> > values (with support of basic operations: >,>=, <, <=, =).
> >
> > I know, I can create several documents for each value, but then I will have
> > an issue with retrieving part of data by ranges (e.g.: I need documents
> > from 10 to 20). There will be duplicates and incorrect ranges.
> >
> > Thanks in advacne for your help!
> >
> > Alexander
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Array as Lucene Field
Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,
You can add multiple values as NumericFields (Lucene 5.x) or PointValues (Lucene 6+). Just create a separate field instance and all all of them. The same applies for all field types.
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Alexander Kozitsin [mailto:askozitsin@gmail.com]
> Sent: Monday, October 10, 2016 12:43 PM
> To: java-user@lucene.apache.org
> Subject: Array as Lucene Field
>
> Hi everyone!
>
> I've faced a problem and had no idea how to resolve it.
>
> So, I've got a directory with documents.
> Each document might contain array of doubles. However, Lucene does not
> support arrays.
> What I need is to have an ability to sort documents by this field, search
> values (with support of basic operations: >,>=, <, <=, =).
>
> I know, I can create several documents for each value, but then I will have
> an issue with retrieving part of data by ranges (e.g.: I need documents
> from 10 to 20). There will be duplicates and incorrect ranges.
>
> Thanks in advacne for your help!
>
> Alexander
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org