lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Salem" <csa...@mainsequence.net>
Subject RE: escaping characters
Date Tue, 12 Aug 2014 12:34:22 GMT
Thanks!  That worked.

We recently upgraded from 2.9 to 4.9, was true the default in 2.9?

-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com] 
Sent: Monday, August 11, 2014 5:54 PM
To: java-user@lucene.apache.org
Subject: Re: escaping characters

You need to manually enable automatic generation of phrase queries - it defaults to disabled,
which simply treats the sub-terms as individual terms subject to the default operator.

See:
http://lucene.apache.org/core/4_9_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#setAutoGeneratePhraseQueries(boolean)

-- Jack Krupansky

-----Original Message-----
From: Chris Salem
Sent: Monday, August 11, 2014 1:03 PM
To: java-user@lucene.apache.org
Subject: RE: escaping characters

I'm not using Solr.  Here's my code:

FSDirectory fsd = FSDirectory.open(new File("C:\\indexes\\Lucene4"));

IndexReader reader = DirectoryReader.open(fsd);

IndexSearcher searcher = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9,
getStopWords());

BooleanQuery.setMaxClauseCount(100000);

QueryParser qptemp = new QueryParser(Version.LUCENE_4_9, "resume_text",analyzer); qptemp.setAllowLeadingWildcard(true);
qptemp.setDefaultOperator(QueryParser.AND_OPERATOR);

Query querytemp = qptemp.parse("resume_text: (LS\\/MS)");

System.out.println(querytemp.toString());
TopFieldCollector tfcollector = TopFieldCollector.create(new Sort(), 20, false, true, false,
true);

ScoreDoc[] hits;
searcher.search(querytemp, tfcollector); hits = tfcollector.topDocs().scoreDocs; long resultCount
= tfcollector.getTotalHits();

reader.close();



-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com]
Sent: Monday, August 11, 2014 12:27 PM
To: java-user
Subject: Re: escaping characters

Take a look at the adnim/analysis page for the field in question.
The next bit of critical information is adding & debug=query to the URL. The former will
tell you what happens to the input stream at query and index time, the latter will tell you
how the query got through the query parsing process.

My guess is that you have WordDelimiterFilterFactory in your analysis chain and that's breaking
things up.

Best,
Erick


On Mon, Aug 11, 2014 at 8:54 AM, Chris Salem <csalem@mainsequence.net>
wrote:

> Hi everyone,
>
>
>
> I'm trying to escape special characters and it doesn't seem to be working.
> If I do a search like resume_text: (LS\/MS) it searches for LS AND MS 
> instead of LS/MS.  How would I escape the slash so it searches for LS/MS?
>
> Thanks
>
>
>
>


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


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



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


Mime
View raw message