View Component 25.2
View Component Help

# Proximity Search Operators

You can apply proximity operators to words, exact phrases, or Boolean expressions to perform a proximity search. Note the following details:

- If the two specified words are adjacent to each other, their proximity is 1. If one word separates them, their distance is 2, and so on.

- Proximity operators do not count stop words. For example, because and is a stop word, the terms cat and dog have the proximity 1 in the text:

  - catdog

  - cat and dog.

- The Content component uses APCM (Adaptive Probabilistic Concept Modeling) to rank results.

- Proximity operators work recursively so that nested Boolean queries can have proximity operators apply to brackets or phrases. For example, in the expression

      (term1) NEAR10 ((term2) DNEAR2 (term3))

  the `NEAR10` operator ensures that term1 is in proximity to an occurrence of term2 within two of term3.

Proximity search operators

Operator | Explanation
--- | ---
`NEARN` | Returns only documents in which the second term is within `N` words of the first term—that is, the terms are `N` or fewer words apart. If you do not specify `N`, `NEAR` defaults to 5. For example:
    action=Query&Text=red+NEAR1+green
This query returns only documents in which the term red is adjacent to the term green. For example, documents that contain red green or green red return. Documents that contain red orange green do not return (because the terms are not close enough to each other).
`DNEARN` | Directed `NEAR`. Returns only documents in which the second term is within `N` words of the first term, in the specified order. If you do not specify `N`, `DNEAR` defaults to 5. For example:
    action=Query&Text=red+DNEAR2+green
This query returns only documents in which the term green follows the term red, and is no more than `two` words away from the term red. For example, documents that contain red orange green return, but documents that contain green orange red or red orange blue green do not return.
`WNEARN` | Weighted `NEAR` (with OR operation). This proximity operator returns documents that contain either of the two terms. It promotes relevance when the terms are `N` or fewer words apart (closer together implies higher relevance). If you do not specify `N`, `WNEAR` defaults to 5. For example:
    action=Query&Text=dog+WNEAR7+cat
This query returns documents that contain either dog or cat. It gives extra relevance to documents in which dog and cat appear seven or fewer words apart in a piece of text. This weight increases as the terms get closer to each other. Documents in which the terms occur more than seven words apart, or in which only one term occurs, return with normal relevance.
`YNEARN` | Weighted `NEAR` (with AND operation). This proximity operator returns documents that contain both of the terms. It promotes relevance when the terms are `N` or fewer words apart (closer together implies higher relevance). If you do not specify `N`, `YNEAR` defaults to 5. For example:
    action=Query&Text=dog+YNEAR7+cat
This query returns documents that contain both dog and cat. It gives extra relevance to documents in which dog and cat appear seven or fewer words apart in a piece of text. This weight increases as the terms get closer to each other. Documents in which the terms occur more than seven words apart return with the normal relevance.
`BEFORE` | Returns only documents in which the first term precedes the second one. For example:
    action=Query&Text=red+BEFORE+green
This query returns only documents in which the term green appears later than the term red. You can also use `BEFORE` for `FieldText` queries. For a `FieldText` query to successfully compare two occurrences of the same field, you must set the `XMLFullStructure` configuration parameter to `True` in the `[Server]` section of the Content component configuration file.
`AFTER` | Returns only documents in which the first term appears later than the second one. For example:
    action=Query&Text=red+AFTER+green
This query returns only documents in which the term red appears later than the term green. You can also use `AFTER` for `FieldText` queries. For a `FieldText` query to successfully compare two occurrences of the same field, you must set the `XMLFullStructure` configuration parameter to `True` in the `[Server]` section of the Content component configuration file.
`XNEAR` | Returns only documents in which the second term is exactly N words from the first term. For example:
    action=Query&Text=cats+XNEAR2+dogs
This query returns only documents in which the term dogs follows the term cats and is exactly two words away from the term cats. This means that documents which contain cats and dogs return, but documents that contain dogs and cats or cats, dogs do not return.
`SENTENCE` | Returns only documents in which the second term is in the same sentence as the first term. For example:
    action=Query&Text=cats+SENTENCE+dogs
This query returns only documents in which the term dogs appears in the same sentence as the word cats. The Content component breaks the document into sentences by using a number of criteria. The most important criteria is the detection of an end of sentence marker, which includes a period (.), question mark (?), or exclamation point (!), as well as their multibyte variants. However, the presence of one of these characters is not always sufficient to mark the end of a sentence, because these characters are often used in abbreviations, names, and other items for purposes other than the end of a sentence. To locate a more accurate sentence boundary, Content also uses characteristics such as capitalization and syntactic observations.
`SENTENCENN` | Returns only documents in which the second term is in the same sentence as the first term, and they are within `NN` words of each other. For example:
    action=Query&Text=cats+SENTENCE10+dogs
This query returns only documents in which the term dogs occurs in the same sentence as, and within 10 words of, the word cats. NOTE: `SENTENCE0` has the same behavior as `SENTENCE`.
`DSENTENCE` | Returns only documents in which the second term occurs later than the first term, in the same sentence. For example:
    action=Query&Text=cats+DSENTENCE+dogs
This query returns only documents in which the term dogs occurs later than the word cats, in the same sentence.
`DSENTENCENN` | Returns only documents in which the second term occurs later than the first term, and within `NN` words in the same sentence. For example:
    action=Query&Text=cats+DSENTENCE10+dogs
This query returns only documents in which the term dogs occurs later in the same sentence than, and within 10 words of, the word cats. NOTE: `DSENTENCE0` has the same behavior as `DSENTENCE`.
`PARAGRAPH` | Returns only documents in which the second term is in the same paragraph as the first term. For example:
    action=Query&Text=red+PARAGRAPH+green
This query returns only documents in which the term green appears in the same paragraph as the word red. The words do not have to be in the same sentence in the paragraph.
`PARAGRAPHNN` | Returns only documents in which the second term is in the same paragraph as the first term, and they are within `NN` words of each other. For example:
    action=Query&Text=cats+PARAGRAPH20+dogs
This query returns only documents in which the term dogs occurs in the same paragraph as, and within 20 words of, the word cats. NOTE: `PARAGRAPH0` has the same behavior as `PARAGRAPH`.

Copyright 2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery View Component 25.2

Topic Title: Proximity Search Operators