Also, I am using the SolrAdmin Analysis UI to verify how Solr is tokenizing
the messages and verifying manually position between tokens.

Debug view of the query side:
For query:
"*params*":{
      "q":"{!lucene}SpanNearQuery(body,(money question),5,true)",
      "df":"body",
      "debug":"true",
      "indent":"true",
      "q.op":"OR",
      "wt":"json"}},

It seems odd that in the parsed query that the "body" field named is
pre-appended to the value 5 and the text true.
  "*debug*":{
    "rawquerystring":"{!lucene}SpanNearQuery(body,(money question),5,true)",
    "querystring":"{!lucene}SpanNearQuery(body,(money question),5,true)",
    "parsedquery":"body:spannearquery (body:body (body:money body:question)
(body:5 body:true))",
    "*parsedquery_toString*":*"body:spannearquery *(body:body (body:money
body:question)* (body:5 body:true*))",
    "explain":{

On Thu, Sep 4, 2025 at 12:04 PM mtn search <search...@gmail.com> wrote:

> Thanks Tim!  Yes I have tried a variety of values and am aware of ordering
> vs non ordering.  I am getting more results than expected and some that do
> not match the proximity criteria.   So when I set it to a small value like
> 2, I was seeking to see the result count drop significantly as many would
> not match criteria.  Unfortunately, the count does not drop.   Looks like a
> fundamental problem with how I am using the syntax.  Still researching, and
> open to suggestions.
>
> Matt
>
> On Thu, Sep 4, 2025 at 11:54 AM Tim Casey <tca...@gmail.com> wrote:
>
>> usually the span and proximities are off-by-one issues.  Specifically the
>> order of the tokens will change the distance calculation.  I do not have
>> an
>> example off the top of my head.   But, when I was doing this, I usually
>> started with a larger span and brought it down through looking at results.
>>
>> This is the case for the old 5~"phrase words" syntax.
>>
>> As an aside, "Not working" is taken by me to mean you are not getting
>> results but the query passes parse.  Not working could mean a lot more in
>> this context.  So I am suggesting, instead of 2, try 10.
>>
>> On Thu, Sep 4, 2025 at 10:43 AM mtn search <search...@gmail.com> wrote:
>>
>> > Hello,
>> >
>> > Looking for guidance on approaches to implement a proximity search
>> between
>> > phrases.
>> >
>> > Initially tried:
>> >
>> >
>> "q":"{!lucene}spanNear(spanNear(spanNear(spanTerm(body:off),spanTerm(body:the),0,true),
>> > spanTerm(body: record),0,true),
>> spanNear(spanTerm(body:new),spanTerm(body:
>> > information),0,true) , 2N,false)",
>> >       "defType":"lucene",
>> >       "df":"body",
>> >
>> > However then simplified to just two terms:
>> > "q":"{!lucene}spanNear(spanTerm(body:off),spanTerm(body:call),2,true)",
>> >       "defType":"lucene",
>> >       "df":"body",
>> >
>> > Both are not working.  Any tips?  Currently on Solr 9.4, but will likely
>> > need to run for some time on a Solr 6 instance.
>> >
>> > Thanks,
>> > Matt
>> >
>>
>

Reply via email to