lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <morus.wal...@tanto.de>
Subject Re: WildCardQuery
Date Tue, 05 Oct 2004 06:37:53 GMT
Robinson Raju writes:
> The way i have done is , 
> if there is a wildcard , Use WildCardQuery , 
> else other.
> Here searchFields is an array which contains the column names . search
> string is the value to be searched.
> 
> if ((searchString.indexOf(IOOSConstants.ASTERISK) > -1)
>                     || (searchString.indexOf(IOOSConstants.QUESTION_MARK) > -1))
>             {
>                 WildcardQuery wQuery = new WildcardQuery(new Term(
>                         searchFields[0], searchString));
>                 booleanQuery.add(wQuery, true, false);
>                 if (searchFields.length > 1)
>                 {
>                     WildcardQuery wQuery2 = new WildcardQuery(new Term(
>                             searchFields[1], searchString));
>                     booleanQuery.add(wQuery2, true, false);
>                 }
>             }
>             else
>             {
>                 Query query = MultiFieldQueryParser.parse(searchString,
>                         searchFields, flags, analyzer);
>                 booleanQuery.add(query, true, false);
>             }
> Query queryfilter = MultiFieldQueryParser.parse(filterString,
>                     filterFields, flags, analyzer);
> QueryFilter queryFilter = new QueryFilter(queryfilter);
> hits = parallelMultiSearcher.search(booleanQuery, queryFilter);
> 
> In the meanwhile , i thought i would tokenize the string based on
> space if the input contains spaces and then add them one by one into
> booleanQuery. But this gave a StringIndexOutOfBoundsException.
> 
> So am still trying...
> Thanks for your help . would appreciate greately if you could give me
> more pointers .
> 
Did you look at the output of query.toString("defaultfield")?
That's usually the best way to see, if a constructed query is what you 
expect it to be.

Why isn't creating wildcard queries left to the query parser?

Morus

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


Mime
View raw message