diff --git a/src/main/java/com/couchbase/intellij/searchworkbench/documentation/CbsJsonDocumentationProvider.java b/src/main/java/com/couchbase/intellij/searchworkbench/documentation/CbsJsonDocumentationProvider.java index ace6fea7..23fb0e52 100644 --- a/src/main/java/com/couchbase/intellij/searchworkbench/documentation/CbsJsonDocumentationProvider.java +++ b/src/main/java/com/couchbase/intellij/searchworkbench/documentation/CbsJsonDocumentationProvider.java @@ -160,6 +160,38 @@ private String getDocumentationForKey(String key, String type) { return ChartUtil.loadResourceAsString("/docs/search/offset.html"); case "fields": return ChartUtil.loadResourceAsString("/docs/search/fields.html"); + case "facets": + return ChartUtil.loadResourceAsString("/docs/search/facets.html"); + case "explain": + return ChartUtil.loadResourceAsString("/docs/search/explain.html"); + case "sort": + return ChartUtil.loadResourceAsString("/docs/search/sort.html"); + case "includeLocations": + return ChartUtil.loadResourceAsString("/docs/search/includeLocations.html"); + case "score": + return ChartUtil.loadResourceAsString("/docs/search/score.html"); + case "search_after": + return ChartUtil.loadResourceAsString("/docs/search/search_after.html"); + case "search_before": + return ChartUtil.loadResourceAsString("/docs/search/search_before.html"); + case "collections": + return ChartUtil.loadResourceAsString("/docs/search/collections.html"); + case "ctl": + return ChartUtil.loadResourceAsString("/docs/search/ctl.html"); + case "timeout": + return ChartUtil.loadResourceAsString("/docs/search/timeout.html"); + case "consistency": + return ChartUtil.loadResourceAsString("/docs/search/consistency.html"); + case "vectors": + return ChartUtil.loadResourceAsString("/docs/search/vectors.html"); + case "level": + return ChartUtil.loadResourceAsString("/docs/search/level.html"); + case "results": + return ChartUtil.loadResourceAsString("/docs/search/results.html"); + case "highlight": + return ChartUtil.loadResourceAsString("/docs/search/highlight.html"); + case "style": + return ChartUtil.loadResourceAsString("/docs/search/style.html"); default: return "No documentation available for this key."; } diff --git a/src/main/java/com/couchbase/intellij/searchworkbench/validator/RootObjectValidator.java b/src/main/java/com/couchbase/intellij/searchworkbench/validator/RootObjectValidator.java index ca521288..c6c34e6a 100644 --- a/src/main/java/com/couchbase/intellij/searchworkbench/validator/RootObjectValidator.java +++ b/src/main/java/com/couchbase/intellij/searchworkbench/validator/RootObjectValidator.java @@ -47,6 +47,11 @@ public void validate(String key, JsonObject jsonObject, ProblemsHolder holder) { holder.registerProblem(jsonObject, getQueryOrKnnReqMessage(), ProblemHighlightType.GENERIC_ERROR); } + if (counter.getOrDefault("search_before", 0) == 1 + && counter.getOrDefault("search_after", 0) == 1) { + holder.registerProblem(jsonObject, "'search_before' and 'search_after' can't be used in the same query", ProblemHighlightType.GENERIC_ERROR); + } + for (Map.Entry entry : counter.entrySet()) { if (entry.getValue() > 1) { holder.registerProblem(jsonObject, getSingleOccurrenceErrorMessage(entry.getKey()), ProblemHighlightType.GENERIC_ERROR); diff --git a/src/main/resources/docs/search/collections.html b/src/main/resources/docs/search/collections.html new file mode 100644 index 00000000..b08d1457 --- /dev/null +++ b/src/main/resources/docs/search/collections.html @@ -0,0 +1,3 @@ + +Contains an array of strings that specify the collections where you want to run the query. + \ No newline at end of file diff --git a/src/main/resources/docs/search/consistency.html b/src/main/resources/docs/search/consistency.html new file mode 100644 index 00000000..067a1db0 --- /dev/null +++ b/src/main/resources/docs/search/consistency.html @@ -0,0 +1,6 @@ + +Use the consistency object to control the consistency behavior for a Search +index

+It contains a vectors object, the level +and results properties. + \ No newline at end of file diff --git a/src/main/resources/docs/search/ctl.html b/src/main/resources/docs/search/ctl.html new file mode 100644 index 00000000..ff68218f --- /dev/null +++ b/src/main/resources/docs/search/ctl.html @@ -0,0 +1,10 @@ + + +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. + \ No newline at end of file diff --git a/src/main/resources/docs/search/explain.html b/src/main/resources/docs/search/explain.html new file mode 100644 index 00000000..733392b8 --- /dev/null +++ b/src/main/resources/docs/search/explain.html @@ -0,0 +1,6 @@ + +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. + \ No newline at end of file diff --git a/src/main/resources/docs/search/facets.html b/src/main/resources/docs/search/facets.html new file mode 100644 index 00000000..8e178d92 --- /dev/null +++ b/src/main/resources/docs/search/facets.html @@ -0,0 +1,15 @@ + +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.

+ + \ No newline at end of file diff --git a/src/main/resources/docs/search/highlight.html b/src/main/resources/docs/search/highlight.html new file mode 100644 index 00000000..6170a355 --- /dev/null +++ b/src/main/resources/docs/search/highlight.html @@ -0,0 +1,11 @@ + +Use the highlight object to control how the Search Service highlights matches in +search results. + +
+    "highlight": {
+        "style": "html",
+        "fields": ["textField"]
+    },
+
+ \ No newline at end of file diff --git a/src/main/resources/docs/search/includeLocations.html b/src/main/resources/docs/search/includeLocations.html new file mode 100644 index 00000000..4eac632c --- /dev/null +++ b/src/main/resources/docs/search/includeLocations.html @@ -0,0 +1,9 @@ + +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.

+ + \ No newline at end of file diff --git a/src/main/resources/docs/search/level.html b/src/main/resources/docs/search/level.html new file mode 100644 index 00000000..59eebde6 --- /dev/null +++ b/src/main/resources/docs/search/level.html @@ -0,0 +1,13 @@ + + +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.

+ \ No newline at end of file diff --git a/src/main/resources/docs/search/results.html b/src/main/resources/docs/search/results.html new file mode 100644 index 00000000..74c62e12 --- /dev/null +++ b/src/main/resources/docs/search/results.html @@ -0,0 +1,8 @@ + +To display an error instead of partial results if any index partitions are unavailable on a node, set results to +complete.

+ +To return partial results from a query if a node is unreachable, remove the results property. + \ No newline at end of file diff --git a/src/main/resources/docs/search/score.html b/src/main/resources/docs/search/score.html new file mode 100644 index 00000000..587c169f --- /dev/null +++ b/src/main/resources/docs/search/score.html @@ -0,0 +1,7 @@ + +To turn off document relevancy scoring in search results, set score to none. +

+ +To turn on document relevancy scoring in search results, remove the score +property. + \ No newline at end of file diff --git a/src/main/resources/docs/search/search_after.html b/src/main/resources/docs/search/search_after.html new file mode 100644 index 00000000..770a1381 --- /dev/null +++ b/src/main/resources/docs/search/search_after.html @@ -0,0 +1,21 @@ + +Use search_after with from/offset and sort to control pagination in search results.

+ +Give a value for each string or JSON object in the sort array to the search_after array. The Search Service starts +search result pagination after the document with those values.

+ +You must provide the values in the same order that they appear in the sort +array.

+ +For example, if you had a set of 10 documents to sort based on _id values of 1-10, with from +set to 2 and search_after set to 8, documents 9-10 appear on the same page. +
+
+
+
+Note: If you use search_after in a search request, you can’t +use search_before. Both properties are included in the example code to show the +correct syntax. + \ No newline at end of file diff --git a/src/main/resources/docs/search/search_before.html b/src/main/resources/docs/search/search_before.html new file mode 100644 index 00000000..7649753e --- /dev/null +++ b/src/main/resources/docs/search/search_before.html @@ -0,0 +1,21 @@ + +Use search_before with from/offset and sort to control pagination in search results.

+ +Give a value for each string or JSON object in the sort array to the search_before array. The Search Service starts +search result pagination before the document with those values.

+ +You must provide the values in the same order that they appear in the sort +array.

+ +For example, if you had a set of 10 documents to sort based on _id values of 1-10, with from +set to 2 and search_before set to 8, documents 2-6 appear on the same page. +
+
+
+
+Note: If you use search_before in a search request, you can’t +use search_after. Both properties are included in the example code to show the +correct syntax. + \ No newline at end of file diff --git a/src/main/resources/docs/search/sort.html b/src/main/resources/docs/search/sort.html new file mode 100644 index 00000000..1b628c30 --- /dev/null +++ b/src/main/resources/docs/search/sort.html @@ -0,0 +1,11 @@ + +Contains an array of strings or JSON objects to set how to sort search results.

+ +The strings can be:

+ +→ {field_name}: Specify the name of a field to use to sort the search results.

+ +→ _id: Use the document’s identifier to sort the search results.

+ +→ _score: Use the document’s score from the Search query to sort the search results. + \ No newline at end of file diff --git a/src/main/resources/docs/search/style.html b/src/main/resources/docs/search/style.html new file mode 100644 index 00000000..f66fa08d --- /dev/null +++ b/src/main/resources/docs/search/style.html @@ -0,0 +1,12 @@ + + +Sets how the Search Service highlights a match from a search query:

+ +→ ansi: The Search Service highlights matches with a yellow background +(\u001b[43m).

+ +→ html: The Search Service surrounds matches with +<mark> and</mark> +HTML tags.

+ + \ No newline at end of file diff --git a/src/main/resources/docs/search/timeout.html b/src/main/resources/docs/search/timeout.html new file mode 100644 index 00000000..5f9b533a --- /dev/null +++ b/src/main/resources/docs/search/timeout.html @@ -0,0 +1,8 @@ + +Set the maximum time, in milliseconds, that a Search query can execute on a Search index partition.

+ +If the query time exceeds the timeout, the Search Service cancels the query. The +query might return partial results if +any index partitions responded before the timeout. + + \ No newline at end of file diff --git a/src/main/resources/docs/search/vectors.html b/src/main/resources/docs/search/vectors.html new file mode 100644 index 00000000..4d0a0987 --- /dev/null +++ b/src/main/resources/docs/search/vectors.html @@ -0,0 +1,4 @@ + +An object that contains a {search-index-name} object for each Search index in +the query. + \ No newline at end of file