NEAR Operator - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.9
Category
Reference Guide

The NEAR operator is used to find documents where queried words are close to each other. Meaning queried words are less distant than a given pathlen.

The NEAR operator can be used in two different ways:

  • Default mode, A NEAR B: this mode uses a 10-word proximity (pathlen=10).
  • Explicit mode, A NEAR(n) B: this mode allows to set a custom proximity (pathlen=n) between A and B.

This operator is able to define proximity between words or between phrases.

When typing A NEAR(n) B, AFS returns all the documents satisfying all the following conditions:

  • The document contains A and B, AND
  • Proximity (pathlen) between the closest instances of A and B in the document is smaller or equal to n.

When typing A B NEAR(n) C D, AFS returns all the documents satisfying all the following conditions:

  • The document contains A, B, C, and D, AND
  • Proximity (pathlen) between the closest instances of B and C in the document is smaller or equal to n.

When typing (A B) NEAR(n) (C D), AFS returns all the documents satisfying all the following conditions:

  • The document contains "A B" and "C D" expressions, AND
  • Proximity (pathlen) between the closest instances of B and C or D and A in the document is smaller or equal to n.

When a proximity operator is used, the abstract snippets only display the search term instances which are near each other.

In case a user runs a query with multiple operators without parenthesis, the order that should prevail to interpret the results is:

  1. OR
    • A OR B NEAR C should be interpreted as (A OR B) NEAR C. In that case, a document is a result if it satisfies A NEAR C, or if it satisfies B NEAR C.
  2. AND
    • A AND B NEAR C should be interpreted as (A AND B) NEAR C. In that case a document is a result if it contains A, and if it contains B, and if it also satisfies B NEAR C.
  3. NOT
    • A NEAR B NOT C should be interpreted as A NEAR (B NOT C). In that case a document is a result if it satisfies B NOT C, and if it also satisfies A NEAR B.
    • A NOT B NEAR C should be interpreted as (A NOT B) NEAR C. In that case a document is a result if it satisfies A NOT B and if it also satisfies A NEAR C.
  4. NEAR

User can always use parenthesis to force a specific interpretation of the operators.

Examples

The following document extract is used for the examples:

...jurisprudence de la Cour de cassation depuis un arrêt de la chambre commerciale...

  • Example 1, query: "Cour de cassation" NEAR(6) "chambre commerciale"
    • B = cassation
    • C = chambre
    • pathlen(B,C) = pathlen(cassation,chambre) = nb_words("depuis un arrêt de la") = 5
    • => the document is showing up as a result since 5 < 6

  • Example 2, query: "chambre commerciale" NEAR(6) "Cour de cassation"
    • B = commerciale
    • C = Cour
    • pathlen(B,C) = pathlen(commerciale,Cour) = nb_words("de cassation depuis un arrêt de la chambre") = 8
    • => the document is not showing up as a result since 8 > 6

  • Example 3, query: "chambre commerciale" NEAR(9) "Cour de cassation"
    • B = commerciale
    • C = Cour
    • pathlen(B,C) = pathlen(commerciale,Cour) = nb_words("de cassation depuis un arrêt de la chambre") = 8
    • => the document is showing up as a result since 8 < 9