You could try something like this, which use when I put my own documents
together:
public Document getDocument(){
Document doc = new Document();
doc.add(new Field("db_key", this.getDb_key(), Field.Store.YES,
Field.Index.UN_TOKENIZED));
doc.add(new Field("acc_ids", this.getAcc_ids(), Field.Store.YES,
Field.Index.TOKENIZED));
doc.add(setBoost(new Field("name", this.getName(),
Field.Store.YES, Field.Index.TOKENIZED), 1.0f));
doc.add(setBoost(new Field("symbol", this.getSymbol(),
Field.Store.YES, Field.Index.TOKENIZED), 1.0f));
doc.add(setBoost(new Field("synonyms", this.getSynonyms(),
Field.Store.YES, Field.Index.TOKENIZED), .8f));
doc.add(setBoost(new Field("allele_nomen",
this.getAllele_nomen(), Field.Store.YES, Field.Index.TOKENIZED), .6f));
doc.add(setBoost(new Field("old_nomen", this.getOld_nomen(),
Field.Store.YES, Field.Index.TOKENIZED), .4f));
doc.add(setBoost(new Field("orth_nomen", this.getOrth_nomen(),
Field.Store.YES, Field.Index.TOKENIZED), .2f));
return doc;
}
private static Field setBoost (Field workField, float boost)
{
workField.setBoost(boost);
return workField;
}
It works out pretty well for me anyhow.
Илья Казначеев wrote:
В сообщении от Thursday 03 April 2008 16:24:15 Илья Казначеев написал(а):
- Is there a way to set weights for different fields? Let's say, content
have a weight of 1, title have a weight of 5 and picture subscribe have a
weight of 0.5. If no, can I do that by hand?
Already found field.setBoost().
Sorry for asking lame questions :(
By the way, if setBoost() returned this, it would be much easier to assemble
document, one line instead of three. Chaining rules.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Matthew Hall
Software Engineer
Mouse Genome Informatics
[EMAIL PROTECTED]
(207) 288-6012
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]