MultiFieldQueryParser Search On C++ problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MultiFieldQueryParser Search On C++ problem

Joe Amstadt
I'm trying to do a search on ( Java PHP C++ ) with
lucene 1.9.  I am using a MultiFieldQueryParser to
parse with StandardAnalyzer. Before I parse the string
I clean up the search string and it looks like this (
Java PHP C\+\+ ).  The query is only searching on "c"
and not "c++" any ideas as to what I am doing wrong at
this point would be great.

MultiFieldQueryParser mfqp = new
MultiFieldQueryParser( str_arr_fields, analyzer );

try{

        System.out.println( "String Before Clean Up --> " +
str_search_value );
        String str_clean_search = stringCleanUp(
str_search_value ); //Escape these special chars +
- && || ! ( ) { } [ ] ^ " ~ * ? : \
        System.out.println( "String After Clean Up --> " +
str_clean_search);
        Query query = mfqp.parse( str_clean_search );
        System.out.println( "Search Query --> " +
query.toString() );
        bq_query.add( query, BooleanClause.Occur.MUST );

}catch( ParseException pe_error ){
                                                                               
        pe_error.printStackTrace();
}

output:

String Before Clean Up --> Java PHP C++
String After Clean Up --> Java PHP C\+\+
Search Query --> ( search_text:java title:java ) (
search_text:php title:php ) ( search_text:c title:c )

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: MultiFieldQueryParser Search On C++ problem

Chris Lamprecht
It's the Analyzer you're passing into the QueryParser.
StandardAnalyzer turns "C++" into "c".  You can change the .jj grammar
to fix this.  (same for "C#")

On 6/14/06, Joe Amstadt <[hidden email]> wrote:

> I'm trying to do a search on ( Java PHP C++ ) with
> lucene 1.9.  I am using a MultiFieldQueryParser to
> parse with StandardAnalyzer. Before I parse the string
> I clean up the search string and it looks like this (
> Java PHP C\+\+ ).  The query is only searching on "c"
> and not "c++" any ideas as to what I am doing wrong at
> this point would be great.
>
> MultiFieldQueryParser mfqp = new
> MultiFieldQueryParser( str_arr_fields, analyzer );
>
> try{
>
>         System.out.println( "String Before Clean Up --> " +
> str_search_value );
>         String str_clean_search = stringCleanUp(
> str_search_value );                             //Escape these special chars +
> - && || ! ( ) { } [ ] ^ " ~ * ? : \
>         System.out.println( "String After Clean Up --> " +
> str_clean_search);
>         Query query = mfqp.parse( str_clean_search );
>         System.out.println( "Search Query --> " +
> query.toString() );
>         bq_query.add( query, BooleanClause.Occur.MUST );
>
> }catch( ParseException pe_error ){
>
>         pe_error.printStackTrace();
> }
>
> output:
>
> String Before Clean Up --> Java PHP C++
> String After Clean Up --> Java PHP C\+\+
> Search Query --> ( search_text:java title:java ) (
> search_text:php title:php ) ( search_text:c title:c )
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]