You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ridwan Habbal <ri...@hotmail.com> on 2007/08/15 11:38:46 UTC

How to search over all fields in a clean way?

Hello all, 
 
when we search over an index docs we use code such:
 
Analyzer analyzer = new StandardAnalyzer();
String defaultSearchField = "all";
QueryParser parser = new QueryParser(defaultSearchField, analyzer);
IndexSearcher indexSearcher = new IndexSearcher(this.indexDirectory);
Hits hits = indexSearcher.search(parser.parse(query));
 
The problem is when you want to search over ALL fields in each doc. What's more is that the fields are created dynamically. In other words, The number and identifiers of the fields of my docs vary from each other. so it's irrational to type all fields names, further more i don't know them. 
I thought of a primitive solution: copy all fields to one field, however this doubles the index size, and it might conflict with some fields names since the fields of docs are dynamic. 
 
could some one help me? 
 
Thanks in advance. 
Ridwan
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

Re: How to search over all fields in a clean way?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
copying all fields to a single searchable field is quite reasonable,  
and won't double your index size if you set the new field to be  
unstored.

	Erik


On Aug 15, 2007, at 5:38 AM, Ridwan Habbal wrote:

> Hello all,
>
> when we search over an index docs we use code such:
>
> Analyzer analyzer = new StandardAnalyzer();
> String defaultSearchField = "all";
> QueryParser parser = new QueryParser(defaultSearchField, analyzer);
> IndexSearcher indexSearcher = new IndexSearcher(this.indexDirectory);
> Hits hits = indexSearcher.search(parser.parse(query));
>
> The problem is when you want to search over ALL fields in each doc.  
> What's more is that the fields are created dynamically. In other  
> words, The number and identifiers of the fields of my docs vary  
> from each other. so it's irrational to type all fields names,  
> further more i don't know them.
> I thought of a primitive solution: copy all fields to one field,  
> however this doubles the index size, and it might conflict with  
> some fields names since the fields of docs are dynamic.
>
> could some one help me?
>
> Thanks in advance.
> Ridwan
> _________________________________________________________________
> Explore the seven wonders of the world
> http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en- 
> US&form=QBRE


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org