Skip to content

Commit

Permalink
Add support for Fts auto Complete and docs + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-pai77 committed Jul 16, 2024
1 parent 7035370 commit a6273b9
Show file tree
Hide file tree
Showing 114 changed files with 5,287 additions and 278 deletions.
55 changes: 55 additions & 0 deletions __mocks__/vscode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// __mocks__/vscode.js

const vscode = {
languages: {
createDiagnosticCollection: jest.fn().mockImplementation(() => {
const diagnosticsMap = new Map();
return {
clear: jest.fn(() => diagnosticsMap.clear()),
dispose: jest.fn(),
get: jest.fn(uri => diagnosticsMap.get(uri.toString())),
set: jest.fn((uri, diagnostics) => diagnosticsMap.set(uri.toString(), diagnostics)),
delete: jest.fn(uri => diagnosticsMap.delete(uri.toString())),
forEach: jest.fn(callback => diagnosticsMap.forEach(callback)),
};
}),
},
Uri: {
parse: jest.fn().mockImplementation((str) => ({
toString: () => str,
})),
},
workspace: {
openTextDocument: jest.fn().mockImplementation((uri) => ({
getText: jest.fn(() => ''),
uri: uri,
positionAt: jest.fn().mockImplementation((index) => {
return new vscode.Position(Math.floor(index / 100), index % 100);
}),
})),
fs: {
writeFile: jest.fn(),
}
},
Range: jest.fn().mockImplementation((start, end) => ({
start: start,
end: end
})),
Position: jest.fn().mockImplementation((line, character) => ({
line: line,
character: character
})),
Diagnostic: jest.fn().mockImplementation((range, message, severity) => ({
range: range,
message: message,
severity: severity
})),
DiagnosticSeverity: {
Error: 0,
Warning: 1,
Information: 2,
Hint: 3
}
};

module.exports = vscode;
7 changes: 7 additions & 0 deletions docs/search/analyzer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Use the **analyzer** property to modify the behavior of a match query or a match phrase query.

Set the **analyzer** property to the name of the analyzer you want to use on the contents of the match property or match_phrase property.

The specified analyzer only applies to the content of your Search request. It does not apply to the contents of documents in the Search index. However, the analyzer set on your Search request and in your Search index should match.

[Additional Query Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#additional-query-properties)
7 changes: 7 additions & 0 deletions docs/search/bool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Use the **bool** property to query a field that contains a boolean value.

Use the field property and set the **bool** property to true or false to run a search.

The Search Service does not use any analyzers on the contents of your query.

[Non-Analytics Query Documentation]("https://docs.couchbase.com/server/current/search/search-request-params.html#non-analytic-queries")
5 changes: 5 additions & 0 deletions docs/search/boost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
If you use multiple clauses in a query, you can use the **boost** property to assign the relative importance to a clause.

Clauses with a higher value in the **boost** property score higher and appear earlier in search results.

[Additional Query Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#additional-query-properties)
11 changes: 11 additions & 0 deletions docs/search/bottom_right.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Set the geo location value to use as the bottom-right corner point of the rectangle search area.

If you use **bottom_right** as an object, you must set two values:

**lon**: The longitude of the geo location to use as the bottom-right corner of the rectangle.

**lat**: The latitude of the geo location to use as the bottom-right corner of the rectangle.

If you use **bottom_right** as an array, your array must contain a longitude value followed by a latitude value. For example, [-2.235143, 53.482358], where -2.235143 is the longitude.

[Rectangle-Based Geopoint Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#geopoint-queries-rectangle)
5 changes: 5 additions & 0 deletions docs/search/cidr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enter an IP address range or single IP address, in IPv4 or IPv6 CIDR notation.

The Search Service returns documents with IP addresses that fall inside the specified range or match the specified IP address.

[IP Address Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#ip-address-range-queries)
3 changes: 3 additions & 0 deletions docs/search/collections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Contains an array of strings that specify the collections where you want to run the query.

[Search Request Json Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html)
9 changes: 9 additions & 0 deletions docs/search/conjuncts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Use the **conjuncts** array to specify multiple child queries in a single query object.

You can use the **conjuncts** array inside a must object or directly inside a query object.

If you use the **conjuncts** array, every query object in the array must have a match in a document to include the document in search results.

You can create objects in a **conjuncts** array to describe any of the available query types.

[Compound Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#boolean-queries)
5 changes: 5 additions & 0 deletions docs/search/consistency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Use the **consistency** object to control the consistency behavior for a Search index

It contains a **vectors** object, the **level** and **results** properties.

[Consistency Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#consistency)
72 changes: 72 additions & 0 deletions docs/search/coordinates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
An array of coordinate floating point values that define the GeoJSON shape.

The Search Service uses the first value in the coordinates array as the longitude value.

#### Point Query
For a **Point** query, set the **coordinates** array to a single array with a longitude and latitude value

#### LineString Query
For a **LineString** query, the **coordinates** array can contain multiple coordinate point arrays.

#### Polygon Query

An array that contains an outer array, and arrays of 2 coordinate floating point values that define the GeoJSON Polygon shape.

The Search Service uses the first value in any nested **coordinates** array as the longitude value for the coordinate.

The Search Service also follows strict GeoJSON syntax, and expects exterior coordinates in a polygon to be in counterclockwise order.

#### MultiPoint Query
An array that contains arrays of 2 coordinate floating point values that define the GeoJSON MultiPoint shape.

#### MultiLineString Query

An array that contains nested arrays, each with their own nested arrays of 2 coordinate floating point values.

For example, the following coordinates array defines 2 LineStrings with start and end points:
"coordinates": [
[
[1.954764, 50.962097], [3.029578, 49.868547]
],
[
[3.029578, 49.868547], [-0.387444, 48.545836]
]
]
The innermost arrays define the individual points for a LineString in the MultiLineString shape.

#### MultiPolygon Query
An array that contains arrays that describe a GeoJSON Polygon shape.

Each inner array that describes a Polygon can contain multiple arrays with 2 coordinate floating point values. These innermost arrays describe the coordinates of the Polygon.

The Search Service also follows strict GeoJSON syntax, and expects exterior coordinates in a polygon to be in counterclockwise order

#### GeometryCollection Query

An array or array of arrays that describes a GeoJSON shape.

The exact structure of the arrays depends on the shape:

→ Point
→ LineString
→ Polygon
→ MultiPoint
→ MultiLineString
→ MultiPolygon

For any array that contains only floating point values, the Search Service uses the first value as the longitude.

The Search Service also follows strict GeoJSON syntax, and expects exterior coordinates in a polygon to be in counterclockwise order.

#### Circle Query
An array of coordinate floating point values that define the center point of the Circle.

Set the **coordinates** array to a single array with a longitude and latitude value.

#### Envelope Query

An array of 2 different arrays that contain coordinate floating point values.

The first **coordinates** nested array contains the minimum longitude and maximum latitude, or the top-left corner of the rectangle.

The second nested array contains the maximum longitude and minimum latitude, or the bottom-right corner.
5 changes: 5 additions & 0 deletions docs/search/ctl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Use the **ctl** object to make sure that the Search Service runs your Search query against the latest version of the documents in your database.

The **ctl** object and its properties cause the Search Service to run your query against the latest version of a document written to a vBucket. The Search Service uses a consistency vector to synchronize the last document write to a vBucket from the Data Service with the Search index.

[Ctl Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#ctl)
9 changes: 9 additions & 0 deletions docs/search/disjuncts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Use the **disjuncts** array to specify multiple child queries in a single query object.

You can use the **disjuncts** array inside a must_not object, should object, or directly inside a query object.

Use a min property to set the number of query objects from the **disjuncts** array that must have a match in a document. If a document does not match the min number of query objects, the Search Service does not include the document in search results.

You can create objects in a **disjuncts** array to describe any of the available query types.

[Compound Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#boolean-queries)
16 changes: 16 additions & 0 deletions docs/search/distance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
The radius where the Search Service should search for matching geo location values.

Enter the radius as a single string, with a numeric value and a unit value. For example, 100.5mi.

You can use the following distance units:

**mm:** Millimeters
**cm:** Centimeters
**in:** Inches
**yd:** Yards
**ft:** Feet
**m:** Meters
**km:** Kilometers
**mi:** Miles

[Distance/Radius-Based Geopoint Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#geopoint-queries-distance)
7 changes: 7 additions & 0 deletions docs/search/end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set the end date of the date range that you want to search for.

You can specify only an **end** value or only a **start** value on your date range.

By default, **end** is exclusive to the range.

[Date Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#date-range-queries)
5 changes: 5 additions & 0 deletions docs/search/explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To create an explanation for a search result's score in search results, set **explain** to true.

To turn off explanations for search result scoring, set **explain** to false.

[Search Request Json Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html)
9 changes: 9 additions & 0 deletions docs/search/facets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Contains **{facet-name}** objects to define each facet you want to return with search results.

The Search Service supports the following facet types:

**Term Facet**: Counts the documents that have the same value for a specified field.

**Numeric Range Facet**: Counts the documents with numeric field values that are greater than or less than a specified range or ranges.

**Date Range Facet**: Counts the documents with date field values that are earlier or later than a specified range or ranges.
3 changes: 3 additions & 0 deletions docs/search/field.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Specify a specific field name, using dot notation, where the Search Service should search for a match to your search query.

[Additional Query Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#additional-query-properties)
5 changes: 5 additions & 0 deletions docs/search/fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
An array of strings to specify each indexed field you want to return in search results.

You must add a field and its contents to a Search index to view it in search results or add it to the **fields** array.

[Search Request Json Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html)
9 changes: 9 additions & 0 deletions docs/search/fuzziness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Use the **fuzziness** property to run a fuzzy query.

The **fuzziness** property uses your specified edit distance to match terms based on their similarity, rather than exact matches.

You can set **fuzziness** to a maximum value of 2.

Use the **fuzziness** property with the term property for a term query or the match property for a match query.

[Additional Query Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#additional-query-properties)
12 changes: 12 additions & 0 deletions docs/search/geometries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Contains objects to define each GeoJSON shape in the GeometryCollection.

Each object in the **geometries** array has a **type** property and a coordinates property.

Set the type property inside the object to the specific shape type you want to define:

→ Point
→ LineString
→ Polygon
→ MultiPoint
→ MultiLineString
→ MultiPolygon
3 changes: 3 additions & 0 deletions docs/search/geometry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Contains the **shape** property and **relation** property.

Defines the GeoJSON shape and how the Search Service should find a match in documents.
10 changes: 10 additions & 0 deletions docs/search/highlight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Use the **highlight** object to control how the Search Service highlights matches in search results.

```json
"highlight": {
"style": "html",
"fields": ["textField"]
},
```

[Highlight Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#highlight)
5 changes: 5 additions & 0 deletions docs/search/includeLocations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To return the position of each occurrence of a search term inside a document, set **includeLocations** to true.

**Note**: You must have *Include Term Vectors* enabled or the **include_term_vectors** property set to true on a field to use **includeLocations**. For more information about how to enable term vectors, see Child Field Options or Search Index JSON Properties.

[Search Request Json Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html)
7 changes: 7 additions & 0 deletions docs/search/inclusive_end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set whether the Search Service should return documents that contain the exact **end** value.

If you set **inclusive_end** to false, only dates earlier than end count as a match to your Search query.

If you do not set the **inclusive_end** value, by default, **end** is exclusive to the range.

[Date Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#date-range-queries)
7 changes: 7 additions & 0 deletions docs/search/inclusive_max.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set whether the Search Service should return documents that contain the exact **max** value.

If you set **inclusive_max** to false, only values less than **max** count as a match to your Search query.

If you do not set the **inclusive_max** value, by default, **max** is exclusive to the range.

[Numeric Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#numeric-range-queries)
7 changes: 7 additions & 0 deletions docs/search/inclusive_min.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set whether the Search Service should return documents that contain the exact **min** value.

If you set **inclusive_min** to false, only values greater than min count as a match to your Search query.

If you do not set the **inclusive_min** value, by default, **min** is inclusive to the range.

[Numeric Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#numeric-range-queries)
7 changes: 7 additions & 0 deletions docs/search/inclusive_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set whether the Search Service should return documents that contain the exact **start** value.

If you set **inclusive_start** to false, only dates later than start count as a match to your Search query.

If you do not set the **inclusive_start** value, by default, **start** is inclusive to the range.

[Date Range Query Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#date-range-queries)
7 changes: 7 additions & 0 deletions docs/search/k.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enter the total number of results that you want to return from your Vector Search query.

The Search Service returns the **k** closest vectors to the vector given in vector.

**NOTE:** The **size** or **limit** property overrides any value set in **k**.

[Knn Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#knn-object)
6 changes: 6 additions & 0 deletions docs/search/knn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Each object inside the knn array in a Search query describes a Vector Search query.
Add the knn array with at least one object to run a Vector Search query

**NOTE:** To run a Vector Search query, you must still include a **query** object with your Search request. To return only results from your Vector Search query, you can set the query object to a **match_none** query. To run a hybrid query that uses regular Search Service parameters together with Vector Search to return results

[Knn Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#knn-object)
1 change: 1 addition & 0 deletions docs/search/lat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The latitude of the geo location
7 changes: 7 additions & 0 deletions docs/search/level.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Set the consistency to bounded or unbounded consistency:

**at_plus**: The Search query executes but requires that the Search index matches the timestamp of the last document update. You must provide a **vectors** object

**not_bounded**: The Search query executes without a consistency requirement. **not_bounded** is faster than **at_plus**, as it doesn't rely on a **vectors** object or wait for the Search index to match the Data Service index.

[Consistency Object Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html#consistency)
5 changes: 5 additions & 0 deletions docs/search/limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Set the total number of results to return for a single page of search results.

If you provide both the **size** and **limit** properties, the Search Service uses the **size** value.

[Search Request Json Documentation](https://docs.couchbase.com/server/current/search/search-request-params.html)
Loading

0 comments on commit a6273b9

Please sign in to comment.