You can do this. It's called adding a Payload. You can add payloads
during Analysis (Token.setPayload()) which means your code below will
need to be changed below such that you use the Field constructor that
takes in a TokenStream and wraps your input tokens. This TokenStream
will also need to add you payloads.
then, during search, you can use a BoostingTermQuery to have the
payload values factor in during scoring.
-Grant
On Nov 18, 2008, at 12:37 PM, T. H. Lin wrote:
I would like to store a set of keywords in a single field of a
document.
for example I have now three keywords: "One", "Two" and "Three"
and I am going to add them into a document.
At first, is this code correct?
/****************************************************************/
String[] keyword = new String[]{"One", "Two", "Three"};
for (int i = 0; i < keyword.length; i++) {
Field f = new Field("field_name",
keyword[i],
Field.Store.NO,
Field.Index.UN_TOKENIZED,
TermVector.YES);
doc.add(f);
}
indexWriter.addDocument(doc);
/***************************************************************/
when searching, We can set Boost for a query term.
the question is...
Can I set Boost for every keyword/term while indexing?
from the example above. I may set those keywords. i.e. "One", "Two"
and
"Three", with different "Weight/Boost/Relavance..." while indexing.
and the same "term" may have different "Weight/Boost/Relavance..." in
different document.
can I do this?
thanks. :-)
--------------------------
Grant Ingersoll
Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]