I want to use a single field to index the document's title and body, in an effort to improve performance.
The idea was to do something like this:
Field title = new Field("text", "alpha bravo charlie", Field.Store.NO, Field.Index.ANALYZED);
title.setBoost(3)
Field body = new Field("text", "delta echo foxtrot", Field.Store.NO, Field.Index.ANALYZED);
Document doc = new Document();
doc.add(title);
doc.add(body);
And then I could just do a single TermQuery
instead of a BooleanQuery
for two separate fields.
However, it turns out that a field boost is the multiple of all the boost of fields of the same name in the document. In my case, it means that both fields have a boost of 3.
Is there a way I can get what I want without resorting to using two different fields? One way would be to add the title
field several times to the document, which increases the term frequency. This works, but seems incredibly brain-dead.
I also know about payloads, but that seems like an overkill for what I'm after.
Any ideas?