lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allison, Timothy B." <>
Subject RE: Question about multi-valued fields
Date Tue, 20 May 2014 15:52:27 GMT
  Good to see you over here.

There's probably an easier way...

I ran into this with geo queries, and the answer there is to test every value in the multi
field for the document that is a hit.

For the text search question, though, you could use analysis and then run a SpanQuery against
your documenta.  You'd get the token offsets and then you could re-analyze to figure out which
field index is your hit.  I have some helper code that I built as part of LUCENE-5317 that
might be of use, but I haven't submitted that updated patch yet.

Stay tuned, though, for the demise of SpanQueries...



From: Chris Bamford []
Sent: Tuesday, May 20, 2014 11:13 AM
Subject: Question about multi-valued fields


Does anyone know a way of identifying which entry in a multi-value field actually matches
during a search?
e.g. in this example:

  String[] entryList = { "entry one", "entry two", "entry three", "entry four" };
  Document doc = new Document();
  for (String entry : Arrays.asList(entryList)) {
        doc.add(new Field("multival-field", entry, Field.Store.NO, Field.Index.NOT_ANALYZED));

Then when we query:

  Query query = new TermQuery(new Term("multival-field", "entry three"));
  TopDocs hits =, 10);

This should match our Document.  At this point is there a way to also find out which entry
in the array making up "multival-field" was responsible?


- Chris
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message