Tim,

The trick is to use PerFieldAnalyzerWrapper with QueryParser, using StandardAnalyzer as the default, and using KeywordAnalyzer for each of the fields that should not be analyzed. KeywordAnalyzer is in the trunk of Subversion right now, not in a released version.

<http://svn.apache.org/repos/asf/lucene/java/trunk/src/java/org/ apache/lucene/analysis/KeywordAnalyzer.java>

It was developed for Lucene in Action also, so it is in that codebase which you can download from http://www.lucenebook.com

Keep in mind that QueryParser may still interfere with keyword fields if there are characters in them that are special to the parser, such as parenthesis.

        Erik



On 24 Nov 2005, at 09:09, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:

Hi,

Our index has a large text field, and a number of "keyword" fields with
things such as the publication code, article reference and so on.

We're analysing using the StandardAnalyzer, which works well. Obviously
the fields which are defined as Field.Keyword don't run through the
analyzer.

The problem comes when we search using a QueryParser. If we've inserted
a field using:

Field.Keyword("pubcode"."PUB123");

We then search using

Query q = QueryParser.parse(query, "text", new StandardAnalyzer());

When we try to search on something like:

"pubcode:PUB123" - the analyzer promptly lowercases the search term, and
we get no hits back.

Is there any way to explain that where a search term is being applied
against a field of type Keyword, that it shouldn't be run through the
analyzer?

We can get around this by creating separate Query objects and joining
them with a BooleanQuery, but we were hoping to be able to handle all of
our queries using QueryParser so that we could easily store queries as
String objects.

Cheers,

Tim.



********************************************************************** ********** The information contained in this email message may be confidential. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. Although this message and any attachments are believed to be free of viruses, no responsibility is accepted by Informa for any loss or damage arising in any way from receipt or use thereof. Messages to and from the company are monitored for operational reasons and in accordance with lawful business practices. If you have received this message in error, please notify us by return and delete the message and any attachments. Further enquiries/returns can be sent to [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to