lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allison, Timothy B." <talli...@mitre.org>
Subject RE: Question about multi-valued fields
Date Tue, 20 May 2014 15:52:27 GMT
Chris,
  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...

Best,

        Tim

________________________________________
From: Chris Bamford [chris.bamford@talktalk.net]
Sent: Tuesday, May 20, 2014 11:13 AM
To: java-user@lucene.apache.org
Subject: Question about multi-valued fields

Hi,

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));
  }
  ...
  iw.addDocument(doc);

Then when we query:

  Query query = new TermQuery(new Term("multival-field", "entry three"));
  TopDocs hits = searcher.search(query, 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?

Thanks,

- Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message