Dear  All

Searcher searcher = new IndexSearcher("C:/index");
Analyzer analyzer = new StandardAnalyzer();
String line="curry asia";  
line=line+"recipe";
String fields[] = new String[2];
fields[0] = "title";
fields[1] = "contents";

Query q = MultiFieldQueryParser.parse(line,fields,analyzer);
Hits hits1 = searcher.search(q);

In the above code Hits will return the documnet  that contains
the word 
1)"Curry OR asia OR recipe"
2)"Curry OR asia AND recipe"
3)"Curry AND asia AND recipe"
4)"Curry AND asia OR recipe"

But I want the result should be
Like this 
1)"Curry AND asia AND recipe"
2)("Curry OR asia) AND recipe"

My question is how to give the condition
Actually my requirement is like this 
User will enter some text in "text box" it may be one word or two word or n word.(Eg 
"curry asia")
but when i am searching i will append "recipe" word in the search string so the search 
must contains "recipe"  word.

Finally search should contains
1)"Curry AND asia AND recipe"
2)("Curry OR asia) AND recipe"

search should not contains
1)"Curry AND asia OR recipe"
2)"Curry OR asia OR recipe"


Thanks and regards
Raju

Reply via email to