lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Rode <martin.r...@programmfabrik.de>
Subject Re: SV: Search in multi fields with cross field AND ?
Date Thu, 04 Aug 2005 12:02:41 GMT
Hi Erlend,

In my case "text" is everything. Whenever I add anything to the index, I 
also add a "text" Field. So in your case, I would build the index like 
you did with an additional

doc.add(Field.Text("text", bean.getCompanyName()));

after each addition.
If you then search, the "text" will give you access to all your data.

Anyway you should definitely get "luke". Browse the index you created!

Best,
Martin



erlend.bjorge@aftenposten.no wrote:

>Hi there Martin!
>
>  
>
>>try this code:
>>QueryParser q = new QueryParser("text", analyzer); 
>>    
>>
>
>What is "text" in this context ? All fields for the Field.text ?
>Or like I understand it, name of a field, like my "keywords1" ??
>
>Anyway, this code didn't work at all with "text" at least, 0 hits,
>Even with one word....  When I e.g. put "keywords1" instead ... 
>it worked for this field of course.
>
>Not sure if you understood my question ? :-) 
>
>---
>
>I create the index like this, I guess I can't prepare the index for
>my multi field, cross field AND search in some way ?
>
>        IndexWriter writer = new IndexWriter(ramDir, getAnalyzer(), true);
>        List companies = retrieveCompanies();
>
>        for(int i=0;i < companies.size(); i++) {
>
>            CompanyBean bean = (CompanyBean) companies.get(i);
>
>            Document doc = new Document();
>            doc.add(Field.Keyword("companyId", "" + bean.getCompanyId()));
>
>            if(bean.getCompanyName() != null){
>                doc.add(Field.Text("companyName", bean.getCompanyName()));
>		}
>		if(bean.getKeywords1() != null) {
>                Field f = Field.Text("keywords1", bean.getKeywords1());
>                f.setBoost(3.0f);
>                doc.add(f);
>            }
>            if(bean.getKeywords2() != null) {
>                Field f = Field.Text("keywords2", bean.getKeywords2());
>                doc.add(f);
>            }
>
>            writer.addDocument(doc, getAnalyzer());
>        }
>
>        int noDocs = writer.docCount();
>
>        writer.optimize();
>        writer.close();
>
>---
>
>    public Analyzer getAnalyzer() {
>        Analyzer analyzer = new StandardAnalyzer();
>        return analyzer;
>    }
>
>---
>
>
>Cheers,
>Erlend
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>For additional commands, e-mail: java-user-help@lucene.apache.org
>
>  
>



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