FAQ
Hi folks!



I'm using Lucene to provide search on my application.



The final query is a BooleanQuery with many fields, there are fields where
I'll look for the entered keyword and some others to restrict the search, as
the id of a category.



I read, and seems to be true, that when using TermQuery, it uses the same
analyzer used when indexing.



As, there are some fields (like category Id) that I don't want to use the
analyzer, the result is not what I expect because the term was analyzed.



My question is: is there any way to search for fields without using an
analyzer?



Thank you!

Search Discussions

  • Testn at Sep 11, 2007 at 1:48 am
    Alice,

    You need to do the following:
    - When you create a document, you need to add category id field using
    something like
    doc.add(new Field(”categoryId”, categoryId, Field.Store.YES,
    Field.Index.UN_TOKENIZED));




    Alice-21 wrote:
    Hi folks!



    I'm using Lucene to provide search on my application.



    The final query is a BooleanQuery with many fields, there are fields where
    I'll look for the entered keyword and some others to restrict the search,
    as
    the id of a category.



    I read, and seems to be true, that when using TermQuery, it uses the same
    analyzer used when indexing.



    As, there are some fields (like category Id) that I don't want to use the
    analyzer, the result is not what I expect because the term was analyzed.



    My question is: is there any way to search for fields without using an
    analyzer?



    Thank you!





    --
    View this message in context: http://www.nabble.com/Query-without-Analyzer-tf4417646.html#a12606415
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Erick Erickson at Sep 11, 2007 at 1:17 pm
    Sure, but it's probably not what you want to do. You can use a
    PerFieldAnalyzerWrapper to analyze different fields with
    different analyzers. So your category field could be both
    indexed and analyzed with, say, WhitespaceAnalyzer or some
    such.

    Or, as testn suggests, store it UN_TOKENIZED.

    Each has its tradeoffs....

    Erick

    On 9/10/07, Alice wrote:

    Hi folks!



    I'm using Lucene to provide search on my application.



    The final query is a BooleanQuery with many fields, there are fields where
    I'll look for the entered keyword and some others to restrict the search,
    as
    the id of a category.



    I read, and seems to be true, that when using TermQuery, it uses the same
    analyzer used when indexing.



    As, there are some fields (like category Id) that I don't want to use the
    analyzer, the result is not what I expect because the term was analyzed.



    My question is: is there any way to search for fields without using an
    analyzer?



    Thank you!




Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedSep 10, '07 at 7:00p
activeSep 11, '07 at 1:17p
posts3
users3
websitelucene.apache.org

3 users in discussion

Alice: 1 post Testn: 1 post Erick Erickson: 1 post

People

Translate

site design / logo © 2022 Grokbase