lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hall <mh...@informatics.jax.org>
Subject Re: Implementing CMS search function using Lucene
Date Thu, 03 Apr 2008 14:51:54 GMT
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: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>   

-- 
Matthew Hall
Software Engineer
Mouse Genome Informatics
mhall@informatics.jax.org
(207) 288-6012



---------------------------------------------------------------------
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