marklogicmarklogic-8

Marklogic search Grammar NEAR Logic


I am using ML search grammar abc NEAR\2 xyz. The issue is NEAR looks in both directions.. Is it possible to tell ML to look in only one direction.


Solution

  • Unfortunately, no. The Search API grammar NEAR/ is parsed into a cts:near-query, which does not have directional options: https://docs.marklogic.com/cts:near-query.

    Update: This is not documented anywhere but it may be worth a try. The Search API implementation appears to support parsing options from grammar definitions using a space delimited options attribute. Although none are provided in the default options, you could override that by defining your own grammar in your search options.

    Something like this might work:

    <search:grammar>
      <search:joiner strength="30" apply="infix" options="ordered"
         element="cts:near-query" tokenize="word">NEAR</search:joiner>
    </search:grammar>