Hi
I've tryed this with MultiPhraseQuery, but it always returns me all
documents of the index, no matter what expression I use.
I've read that adding a set of terms wich their values are all the entered
query (e.g. "str"), the search works as the symbol "*" (e.g. "str*"), so I
tryed that.
My code is like this:
// prompt the user
System.out.println("Enter query: ");
String line = in.readLine(); //if I put "str", I want all matches like
"string", "strong", "astray"....
line = line.trim();
//I thought this would be ok...
MultiPhraseQuery mpquery = new MultiPhraseQuery();
TermEnum te = reader.terms(new Term("contents",line));
/*Home-made conversion from TermEnum to Term[]... I get just 200 matches, I
don't want my
machine busy...*/
Term[] terms = new Term[200];
int j=0;
while(te.next() && j<200){
terms[j] = te.term();
j++;
}
mpquery.add(terms);
Query query = parser.parse(line);
System.out.println("Searching for: " + query.toString(field));
Date start = new Date();
Hits hits = searcher.search(mpquery);
for(int k = 0; k<100; k++){
//when I print the results of the search, none of the values match with
the query...
System.out.println(hits.doc(k).getField("contents").stringValue());
}
Ian Lea wrote:
>
> Hi
>
>
> This is possible. There is an entry on wildcards in the FAQ. See
> also RegexQuery and search the mailing lists for ngrams.
>
> Depending on your setup and requirements you may need to be aware of
> the performance implications of wild card searching, particularly
> leading wildcards as will be required for the example you give. See
> the FAQ and javadocs for WildcardQuery.
>
>
> --
> Ian.
>
> On Thu, Apr 30, 2009 at 11:46 AM, Huntsman84 <[email protected]> wrote:
>>
>> Hello,
>>
>>
>>
>> I am new to Lucene, and I don't know if it is possible to obtain results
>> providing part of the keyword.
>>
>>
>>
>> For example, if I try to search "in", it should return all matches with
>> "string", "meaning", "trinity"...
>>
>>
>>
>> Am I expecting too much?
>>
>>
>>
>> Thank you so much!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/Searching-for-partial-matches-tp23313810p23370618.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]