Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:57:06+00:00 2026-06-05T08:57:06+00:00

How can I do a proximity search for two multi-word phrases in Lucene. For

  • 0

How can I do a proximity search for two multi-word phrases in Lucene. For example, I want to find all
black lab* (black labrador, black labradoodle, etc) withing 5 words of the phrase “pet shop”. Which analyzer should I be using? Which query parser would be recommended? I’m working with Lucene.NET. I’ve ported the ComplexPhraseQueryParser from Java to C#, but that parser doesn’t seem to be doing the trick (or perhaps I’m just using it wrong). I’m just getting started with Lucene, so your help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:57:07+00:00Added an answer on June 5, 2026 at 8:57 am

    You can use a SpanQuery for this:

    new SpanNearQuery(
        new SpanQuery[] {
            new SpanNearQuery(
                new SpanQuery[] {
                    new SpanTermQuery(new Term(FIELD, "black")),
                    new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term(FIELD, "lab*"))),
                },
                0,
                true),
            new SpanNearQuery(
                new SpanQuery[] {
                    new SpanTermQuery(new Term(FIELD, "pet")),
                    new SpanTermQuery(new Term(FIELD, "shop")),
                },
                0,
                true),
        },
        5,
        true);
    

    The default Lucene QueryParser doesn’t support span queries, but you could try the Surround query parser. I couldn’t find much else in the way of documentation.

    You may also find this answer and this blog post useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to implement proximity search using Lucene 3.6 . I went
i am working on app which deals with proximity alerts. I can add proximity
Google's query syntax allows to search phrases like as * as a skyscraper where
I'm trying to handle proximity search for a basic store locater in Django. Rather
I want to find people around X miles let me explain it properly. I
How can I use proximity alerts on my Google Maps activity? This proximity alerts
While I can hack together code to draw an XY plot, I want some
My application performs a number of UI updates in close proximity, for example: User
I am trying to write a php function that calculates proximity between two points
I want to create an iPhone application that can call web services on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.