FAQ
Hi,

I have a tags field. And each tag can have multiple words, like "San
Francisco". Each tag is analyzed into Keyword field like this
new Field("tags", "San Francisco",Field.Store.YES,
Field.Index.UN_TOKENIZED)

It should be searchable if using TermQuery directly, like
new TermQuery(new Term("tags", "San Francisco"))

But how to achieve this via Lucene Query Parser? If using
tags:"San Francisco"
It's considered a phrase, and turned into term search of tags:San and
tags:Francisco, which will not return results.

Thanks for any advice!

--
Chris Lu
-------------------------
Instant Scalable Full-Text Search On Any Database/Application
site: http://www.dbsight.net
demo: http://search.dbsight.com
Lucene Database Search in 3 minutes:
http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
DBSight customer, a shopping comparison site, (anonymous per request) got
2.6 Million Euro funding!

Search Discussions

  • Yonik Seeley at Jun 25, 2008 at 12:26 am
    You can backslash escape spaces, so these should both work:
    tags:San\ Francisco
    tags:"San\ Francisco"

    -Yonik
    On Tue, Jun 24, 2008 at 8:14 PM, Chris Lu wrote:
    I have a tags field. And each tag can have multiple words, like "San
    Francisco". Each tag is analyzed into Keyword field like this
    new Field("tags", "San Francisco",Field.Store.YES,
    Field.Index.UN_TOKENIZED)

    It should be searchable if using TermQuery directly, like
    new TermQuery(new Term("tags", "San Francisco"))

    But how to achieve this via Lucene Query Parser? If using
    tags:"San Francisco"
    It's considered a phrase, and turned into term search of tags:San and
    tags:Francisco, which will not return results.

    Thanks for any advice!

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Chris Lu at Jun 25, 2008 at 12:41 am
    Yonik, Thanks for your quick reply!

    But I found after backslash escape spaces, both
    tags:San\ Francisco
    tags:"San\ Francisco"
    turns into PhraseQuery, just like tags:"San Francisco", still no results
    returned.

    Maybe Lucene Query Parser does not handle this case?

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    On Tue, Jun 24, 2008 at 5:26 PM, Yonik Seeley wrote:

    You can backslash escape spaces, so these should both work:
    tags:San\ Francisco
    tags:"San\ Francisco"

    -Yonik
    On Tue, Jun 24, 2008 at 8:14 PM, Chris Lu wrote:
    I have a tags field. And each tag can have multiple words, like "San
    Francisco". Each tag is analyzed into Keyword field like this
    new Field("tags", "San Francisco",Field.Store.YES,
    Field.Index.UN_TOKENIZED)

    It should be searchable if using TermQuery directly, like
    new TermQuery(new Term("tags", "San Francisco"))

    But how to achieve this via Lucene Query Parser? If using
    tags:"San Francisco"
    It's considered a phrase, and turned into term search of tags:San and
    tags:Francisco, which will not return results.

    Thanks for any advice!

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Erick Erickson at Jun 25, 2008 at 1:02 am
    What analyzers are you using for both indexing and querying?
    Have you looked at your index with Luke to see what's actually
    in the index? The reason I'm asking is I'm wondering whether you
    are having capitalization issues. That is, your index analyzer
    lower cases the tokens and your query analyzer doesn't, or
    vice-versa...

    And Query.toString is your friend too <G>.

    Best
    Erick
    On Tue, Jun 24, 2008 at 8:40 PM, Chris Lu wrote:

    Yonik, Thanks for your quick reply!

    But I found after backslash escape spaces, both
    tags:San\ Francisco
    tags:"San\ Francisco"
    turns into PhraseQuery, just like tags:"San Francisco", still no results
    returned.

    Maybe Lucene Query Parser does not handle this case?

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:

    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    On Tue, Jun 24, 2008 at 5:26 PM, Yonik Seeley wrote:

    You can backslash escape spaces, so these should both work:
    tags:San\ Francisco
    tags:"San\ Francisco"

    -Yonik
    On Tue, Jun 24, 2008 at 8:14 PM, Chris Lu wrote:
    I have a tags field. And each tag can have multiple words, like "San
    Francisco". Each tag is analyzed into Keyword field like this
    new Field("tags", "San Francisco",Field.Store.YES,
    Field.Index.UN_TOKENIZED)

    It should be searchable if using TermQuery directly, like
    new TermQuery(new Term("tags", "San Francisco"))

    But how to achieve this via Lucene Query Parser? If using
    tags:"San Francisco"
    It's considered a phrase, and turned into term search of tags:San and
    tags:Francisco, which will not return results.

    Thanks for any advice!

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request)
    got
    2.6 Million Euro funding!
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Chris Lu at Jun 25, 2008 at 3:44 am
    Erick, Thanks!

    It's the analyzer problem. I should have used the same analyzer,
    KeywordAnalyzer, to create the query parser.

    Thanks a lot!

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    On Tue, Jun 24, 2008 at 6:02 PM, Erick Erickson wrote:

    What analyzers are you using for both indexing and querying?
    Have you looked at your index with Luke to see what's actually
    in the index? The reason I'm asking is I'm wondering whether you
    are having capitalization issues. That is, your index analyzer
    lower cases the tokens and your query analyzer doesn't, or
    vice-versa...

    And Query.toString is your friend too <G>.

    Best
    Erick
    On Tue, Jun 24, 2008 at 8:40 PM, Chris Lu wrote:

    Yonik, Thanks for your quick reply!

    But I found after backslash escape spaces, both
    tags:San\ Francisco
    tags:"San\ Francisco"
    turns into PhraseQuery, just like tags:"San Francisco", still no results
    returned.

    Maybe Lucene Query Parser does not handle this case?

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:

    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request) got
    2.6 Million Euro funding!
    On Tue, Jun 24, 2008 at 5:26 PM, Yonik Seeley wrote:

    You can backslash escape spaces, so these should both work:
    tags:San\ Francisco
    tags:"San\ Francisco"

    -Yonik
    On Tue, Jun 24, 2008 at 8:14 PM, Chris Lu wrote:
    I have a tags field. And each tag can have multiple words, like "San
    Francisco". Each tag is analyzed into Keyword field like this
    new Field("tags", "San Francisco",Field.Store.YES,
    Field.Index.UN_TOKENIZED)

    It should be searchable if using TermQuery directly, like
    new TermQuery(new Term("tags", "San Francisco"))

    But how to achieve this via Lucene Query Parser? If using
    tags:"San Francisco"
    It's considered a phrase, and turned into term search of tags:San and
    tags:Francisco, which will not return results.

    Thanks for any advice!

    --
    Chris Lu
    -------------------------
    Instant Scalable Full-Text Search On Any Database/Application
    site: http://www.dbsight.net
    demo: http://search.dbsight.com
    Lucene Database Search in 3 minutes:
    http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
    DBSight customer, a shopping comparison site, (anonymous per request)
    got
    2.6 Million Euro funding!
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedJun 25, '08 at 12:15a
activeJun 25, '08 at 3:44a
posts5
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase