Search code examples
lucenelucene.net

How to do pattern matching in Lucene.Net?


I have created a Lucene index which has unique street name as below

StreetName
~~~~~~~~~
13th Avenue
13th Street

Now if I have a search-string as '1204 13th Avenue TAMPA', how can i create a query that returns me the matching terms from the Lucene index i.e. '13th Avenue'


Solution

  • This should match what you require. Providing the words weren't in your ignore list when creating the index.

    StreetName: ("1204" "13th" "Avenue" "TAMPA")
    

    See here for some more details on query syntax http://lucene.apache.org/core/old_versioned_docs/versions/2_9_1/queryparsersyntax.html

    Related Answer How do I perform an AND search in Lucene.net when multiple words are used in a search?