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 Niall Lennon <ni...@hotmail.com> on 2003/09/22 00:13:58 UTC

MultiFieldQueryParser & Phrases Problem

I'm currently using the MultiFieldQueryParser to search across four fields. 
I'm searching for phrases so i've wrapped my search text in quotes... 
everything worked
fine until i tried to execute a search ending with the 'A' and for some 
reason the A and quotes are ignored e.g.:


Analyzer analyzer = new StandardAnalyzer();
Searcher searcher = new IndexSearcher(IndexReader.open("dbindex"));

String[] fields = {"code_field", "short_description_field", 
"category_field", "manufacturer_field"};
int[] flags = {MultiFieldQueryParser.NORMAL_FIELD, 
MultiFieldQueryParser.NORMAL_FIELD, MultiFieldQueryParser.NORMAL_FIELD, 
MultiFieldQueryParser.NORMAL_FIELD};

Query query =    MultiFieldQueryParser.parse("\"Category A\"", fields, 
flags, analyzer);

System.out.println("query -> " + query);

Hits hits = searcher.search(query);



The System output for the above is as follows:
code_field:category short_description_field:category category_field:category 
manufacturer_field:category



If i execute the same code with the following search text i get the expected 
results:
Query query =    MultiFieldQueryParser.parse("\"Category Z\"", fields, 
flags, analyzer);


code_field:"category z" short_description_field:"category z" 
category_field:"category z" manufacturer_field:"category z"



I' appreicate any help with regards this matter...

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


Re: MultiFieldQueryParser & Phrases Problem

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
StandardAnalyzer removes stop words and "a" is one of them.  That is 
why you have issues with that phrase.

	Erik


On Sunday, September 21, 2003, at 06:13  PM, Niall Lennon wrote:

> I'm currently using the MultiFieldQueryParser to search across four 
> fields. I'm searching for phrases so i've wrapped my search text in 
> quotes... everything worked
> fine until i tried to execute a search ending with the 'A' and for 
> some reason the A and quotes are ignored e.g.:
>
>
> Analyzer analyzer = new StandardAnalyzer();
> Searcher searcher = new IndexSearcher(IndexReader.open("dbindex"));
>
> String[] fields = {"code_field", "short_description_field", 
> "category_field", "manufacturer_field"};
> int[] flags = {MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD};
>
> Query query =    MultiFieldQueryParser.parse("\"Category A\"", fields, 
> flags, analyzer);
>
> System.out.println("query -> " + query);
>
> Hits hits = searcher.search(query);
>
>
>
> The System output for the above is as follows:
> code_field:category short_description_field:category 
> category_field:category manufacturer_field:category
>
>
>
> If i execute the same code with the following search text i get the 
> expected results:
> Query query =    MultiFieldQueryParser.parse("\"Category Z\"", fields, 
> flags, analyzer);
>
>
> code_field:"category z" short_description_field:"category z" 
> category_field:"category z" manufacturer_field:"category z"
>
>
>
> I' appreicate any help with regards this matter...
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE* 
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: MultiFieldQueryParser & Phrases Problem

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
StandardAnalyzer removes stop words and "a" is one of them.  That is 
why you have issues with that phrase.

	Erik


On Sunday, September 21, 2003, at 06:13  PM, Niall Lennon wrote:

> I'm currently using the MultiFieldQueryParser to search across four 
> fields. I'm searching for phrases so i've wrapped my search text in 
> quotes... everything worked
> fine until i tried to execute a search ending with the 'A' and for 
> some reason the A and quotes are ignored e.g.:
>
>
> Analyzer analyzer = new StandardAnalyzer();
> Searcher searcher = new IndexSearcher(IndexReader.open("dbindex"));
>
> String[] fields = {"code_field", "short_description_field", 
> "category_field", "manufacturer_field"};
> int[] flags = {MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD, 
> MultiFieldQueryParser.NORMAL_FIELD};
>
> Query query =    MultiFieldQueryParser.parse("\"Category A\"", fields, 
> flags, analyzer);
>
> System.out.println("query -> " + query);
>
> Hits hits = searcher.search(query);
>
>
>
> The System output for the above is as follows:
> code_field:category short_description_field:category 
> category_field:category manufacturer_field:category
>
>
>
> If i execute the same code with the following search text i get the 
> expected results:
> Query query =    MultiFieldQueryParser.parse("\"Category Z\"", fields, 
> flags, analyzer);
>
>
> code_field:"category z" short_description_field:"category z" 
> category_field:"category z" manufacturer_field:"category z"
>
>
>
> I' appreicate any help with regards this matter...
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE* 
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


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