---
title: "SearchAdjustment"
language: "en"
type: "Symbol"
summary: "SearchAdjustment[query, w] represents a component of a search query that is to be treated as having weight w. SearchAdjustment[query, ..., opts] represents a component of a search query with certain options."
keywords: 
- search term weight
canonical_url: "https://reference.wolfram.com/language/ref/SearchAdjustment.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Text Search"
    link: "https://reference.wolfram.com/language/guide/TextSearch.en.md"
related_functions: 
  - 
    title: "TextSearch"
    link: "https://reference.wolfram.com/language/ref/TextSearch.en.md"
  - 
    title: "ContentFieldOptions"
    link: "https://reference.wolfram.com/language/ref/ContentFieldOptions.en.md"
---
[EXPERIMENTAL]

# SearchAdjustment

SearchAdjustment[query, w] represents a component of a search query that is to be treated as having weight w.

SearchAdjustment[query, …, opts] represents a component of a search query with certain options.

## Details and Options

* Query components without ``SearchAdjustment[…]`` are effectively treated as having weight 1.

* In ``SearchAdjustment[query, w]``, larger weights ``w`` make this component be considered more important for purposes of ranking search results.

* Possible options for ``SearchAdjustment`` include:

[`MaxWordGap`](https://reference.wolfram.com/language/ref/MaxWordGap.en.md) 	0	maximum gap in words allowed between tokens

---

## Examples (4)

### Basic Examples (1)

Create an example index:

```wl
In[1]:= index = CreateSearchIndex["ExampleData/Text"];
```

Give more weight to documents containing the word "dog":

```wl
In[2]:= TextSearch[index, SearchAdjustment["dog", 20] | "lorem"][All]

Out[2]=
{ContentObject[Association["CreationDate" -> DateObject[{2025, 6, 3, 5, 27, 7}, "Instant", 
    "Gregorian", -5.], "FileByteCount" -> 893121, "FileExtension" -> "txt", 
  "FileName" -> "OriginOfSpecies.txt", "Location" -> "/Applications/Wolfram/14. ... ext", "lorem"} -> 7, 
    {"Title", "lorem"} -> 1, {"FileName", "lorem"} -> 1], "Title" -> "LoremIpsum", 
  "ReferenceLocation" -> "/Applications/Wolfram/14.3.0.W.app/Contents/SystemFiles/Components/TextSe\
arch/ExampleData/Text/LoremIpsum.txt"]]}
```

Without the extra weight, a different ranking is given:

```wl
In[3]:= TextSearch[index, "dog" | "lorem"][All]

Out[3]=
{ContentObject[Association["CreationDate" -> DateObject[{2025, 6, 3, 5, 27, 7}, "Instant", 
    "Gregorian", -5.], "FileByteCount" -> 6456, "FileExtension" -> "txt", 
  "FileName" -> "LoremIpsum.txt", "Location" -> "/Applications/Wolfram/14.3.0.W.a ... 19795227, 
  "TermFrequencies" -> Association[{"Plaintext", "dog"} -> 2], "Title" -> "AeneidEnglish", 
  "ReferenceLocation" -> "/Applications/Wolfram/14.3.0.W.app/Contents/SystemFiles/Components/TextSe\
arch/ExampleData/Text/AeneidEnglish.txt"]]}
```

### Scope (2)

Queries can have multiple adjusted components:

```wl
In[1]:= TextSearch[CreateSearchIndex["ExampleData/Text"], SearchAdjustment["dog", 7] | SearchAdjustment["lorem", 1.5]][All]

Out[1]=
{ContentObject[Association["CreationDate" -> DateObject[{2025, 6, 3, 5, 27, 7}, "Instant", 
    "Gregorian", -5.], "FileByteCount" -> 6456, "FileExtension" -> "txt", 
  "FileName" -> "LoremIpsum.txt", "Location" -> "/Applications/Wolfram/14.3.0.W.a ... 43972778, 
  "TermFrequencies" -> Association[{"Plaintext", "dog"} -> 2], "Title" -> "AeneidEnglish", 
  "ReferenceLocation" -> "/Applications/Wolfram/14.3.0.W.app/Contents/SystemFiles/Components/TextSe\
arch/ExampleData/Text/AeneidEnglish.txt"]]}
```

---

If the given weight is less than 1, the adjusted component is given less importance:

```wl
In[1]:= TextSearch[CreateSearchIndex["ExampleData/Text"], SearchAdjustment["dog", 3] | SearchAdjustment["lorem", 0.5]][All]

Out[1]=
{ContentObject[Association["CreationDate" -> DateObject[{2025, 6, 3, 5, 27, 7}, "Instant", 
    "Gregorian", -5.], "FileByteCount" -> 6456, "FileExtension" -> "txt", 
  "FileName" -> "LoremIpsum.txt", "Location" -> "/Applications/Wolfram/14.3.0.W.a ... 63961792, 
  "TermFrequencies" -> Association[{"Plaintext", "dog"} -> 2], "Title" -> "AeneidEnglish", 
  "ReferenceLocation" -> "/Applications/Wolfram/14.3.0.W.app/Contents/SystemFiles/Components/TextSe\
arch/ExampleData/Text/AeneidEnglish.txt"]]}
```

### Options (1)

#### MaxWordGap (1)

Allow a gap of 1 word to occur between "some" and "extracts":

```wl
In[1]:=
index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchAdjustment["some extracts", MaxWordGap -> 1]][All]

Out[1]=
{ContentObject[Association["CreationDate" -> DateObject[{2025, 6, 3, 5, 27, 7}, "Instant", 
    "Gregorian", -5.], "FileByteCount" -> 893121, "FileExtension" -> "txt", 
  "FileName" -> "OriginOfSpecies.txt", "Location" -> "/Applications/Wolfram/14.3 ... ociation[{"Plaintext", "extract"} -> 2, {"Plaintext", "some"} -> 658], 
  "Title" -> "OriginOfSpecies", "ReferenceLocation" -> "/Applications/Wolfram/14.3.0.W.app/Contents\
/SystemFiles/Components/TextSearch/ExampleData/Text/OriginOfSpecies.txt"]]}
```

## See Also

* [`TextSearch`](https://reference.wolfram.com/language/ref/TextSearch.en.md)
* [`ContentFieldOptions`](https://reference.wolfram.com/language/ref/ContentFieldOptions.en.md)

## Related Guides

* [Text Search](https://reference.wolfram.com/language/guide/TextSearch.en.md)

## History

* [Introduced in 2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md)