Skip to content

Commit

Permalink
finishing the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
deniswsrosa committed May 19, 2024
1 parent 6f57b7b commit 7407a75
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Integer> entry : counter.entrySet()) {
if (entry.getValue() > 1) {
holder.registerProblem(jsonObject, getSingleOccurrenceErrorMessage(entry.getKey()), ProblemHighlightType.GENERIC_ERROR);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/docs/search/collections.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
Contains an array of strings that specify the collections where you want to run the query.
</html>
6 changes: 6 additions & 0 deletions src/main/resources/docs/search/consistency.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
Use the <strong style="color: #6aab73">consistency</strong> object to control the consistency behavior for a Search
index<br><br>
It contains a <strong style="color: #6aab73">vectors</strong> object, the <strong style="color: #6aab73">level</strong>
and <strong style="color: #6aab73">results</strong> properties.
</html>
10 changes: 10 additions & 0 deletions src/main/resources/docs/search/ctl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>

Use the <strong style="color: #6aab73">ctl</strong> object to make sure that the Search Service runs your Search query
against the latest version of the
documents in your database.<br><br>

The <strong style="color: #6aab73">ctl</strong> 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.
</html>
6 changes: 6 additions & 0 deletions src/main/resources/docs/search/explain.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
To create an explanation for a search result’s score in search results, set <strong
style="color: #6aab73">explain</strong> to true.<br><br>

To turn off explanations for search result scoring, set <strong style="color: #6aab73">explain</strong> to false.
</html>
15 changes: 15 additions & 0 deletions src/main/resources/docs/search/facets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
Contains <strong style="color: #6aab73">{facet-name}</strong> objects to define each facet you want to return with
search results.<br><br>

The Search Service supports the following facet types:<br><br>

&rarr; <strong>Term Facet</strong>: Counts the documents that have the same value for a specified field.<br><br>

&rarr; <strong>Numeric Range Facet</strong>: Counts the documents with numeric field values that are greater than or
less than a specified range or ranges.<br><br>

&rarr; <strong>Date Range Facet</strong>: Counts the documents with date field values that are earlier or later than a
specified range or ranges.<br><br>

</html>
11 changes: 11 additions & 0 deletions src/main/resources/docs/search/highlight.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
Use the <strong style="color: #6aab73">highlight</strong> object to control how the Search Service highlights matches in
search results.

<pre>
"highlight": {
"style": "html",
"fields": ["textField"]
},
</pre>
</html>
9 changes: 9 additions & 0 deletions src/main/resources/docs/search/includeLocations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
To return the position of each occurrence of a search term inside a document, set <strong style="color: #6aab73">includeLocations</strong>
to true.<br><br>

<strong>Note</strong>: You must have <i>Include Term Vectors</i> enabled or the <strong style="color: #6aab73">include_term_vectors</strong>
property set to true on a field to use <strong style="color: #6aab73">includeLocations</strong>. For more information
about how to enable term vectors, see Child Field Options or Search Index JSON Properties.<br><br>

</html>
13 changes: 13 additions & 0 deletions src/main/resources/docs/search/level.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>

Set the consistency to bounded or unbounded consistency:<br><br>

&rarr; <strong style="color: #6aab73">at_plus</strong>: The Search query executes but requires that the Search index
matches the timestamp of the last document update.
You must provide a <strong style="color: #6aab73">vectors</strong> object<br><br>

&rarr; <strong style="color: #6aab73">not_bounded</strong>: The Search query executes without a consistency requirement.
<strong style="color: #6aab73">not_bounded</strong> is faster than <strong style="color: #6aab73">at_plus</strong>, as
it doesn't rely on a <strong style="color: #6aab73">vectors</strong> object or wait for the Search index to match the
Data Service index.<br><br>
</html>
8 changes: 8 additions & 0 deletions src/main/resources/docs/search/results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
To display an error instead of partial results if any index partitions are unavailable on a node, set <strong
style="color: #6aab73">results</strong> to
<strong style="color: #6aab73">complete</strong>.<br><br>

To return partial results from a query if a node is unreachable, remove the <strong
style="color: #6aab73">results</strong> property.
</html>
7 changes: 7 additions & 0 deletions src/main/resources/docs/search/score.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/html">
To turn off document relevancy scoring in search results, set <strong style="color: #6aab73">score</strong> to none.
<br><br>

To turn on document relevancy scoring in search results, remove the <strong style="color: #6aab73">score</strong>
property.
</html>
21 changes: 21 additions & 0 deletions src/main/resources/docs/search/search_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html>
Use <strong style="color: #6aab73">search_after</strong> with <strong style="color: #6aab73">from</strong>/<strong
style="color: #6aab73">offset</strong> and sort to control pagination in search results.<br><br>

Give a value for each string or JSON object in the <strong style="color: #6aab73">sort</strong> array to the <strong
style="color: #6aab73">search_after</strong> array. The Search Service starts
search result pagination after the document with those values.<br><br>

You must provide the values in the same order that they appear in the <strong style="color: #6aab73">sort</strong>
array.<br><br>

For example, if you had a set of 10 documents to sort based on _id values of 1-10, with <strong style="color: #6aab73">from</strong>
set to 2 and <strong style="color: #6aab73">search_after</strong> set to 8, documents 9-10 appear on the same page.
<br>
<br>
<hr style="border: 0; height: 1px; background-color: dimgray;">
<br>
<strong>Note</strong>: If you use <strong style="color: #6aab73">search_after</strong> in a search request, you can’t
use <strong style="color: #6aab73">search_before</strong>. Both properties are included in the example code to show the
correct syntax.
</html>
21 changes: 21 additions & 0 deletions src/main/resources/docs/search/search_before.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html>
Use <strong style="color: #6aab73">search_before</strong> with <strong style="color: #6aab73">from</strong>/<strong
style="color: #6aab73">offset</strong> and sort to control pagination in search results.<br><br>

Give a value for each string or JSON object in the <strong style="color: #6aab73">sort</strong> array to the <strong
style="color: #6aab73">search_before</strong> array. The Search Service starts
search result pagination before the document with those values.<br><br>

You must provide the values in the same order that they appear in the <strong style="color: #6aab73">sort</strong>
array.<br><br>

For example, if you had a set of 10 documents to sort based on _id values of 1-10, with <strong style="color: #6aab73">from</strong>
set to 2 and <strong style="color: #6aab73">search_before</strong> set to 8, documents 2-6 appear on the same page.
<br>
<br>
<hr style="border: 0; height: 1px; background-color: dimgray;">
<br>
<strong>Note</strong>: If you use <strong style="color: #6aab73">search_before</strong> in a search request, you can’t
use <strong style="color: #6aab73">search_after</strong>. Both properties are included in the example code to show the
correct syntax.
</html>
11 changes: 11 additions & 0 deletions src/main/resources/docs/search/sort.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
Contains an array of strings or JSON objects to set how to sort search results.<br><br>

The strings can be:<br><br>

&rarr; <strong>{field_name}</strong>: Specify the name of a field to use to sort the search results.<br><br>

&rarr; <strong>_id</strong>: Use the document’s identifier to sort the search results.<br><br>

&rarr; <strong>_score</strong>: Use the document’s score from the Search query to sort the search results.
</html>
12 changes: 12 additions & 0 deletions src/main/resources/docs/search/style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>

Sets how the Search Service highlights a match from a search query:<br><br>

&rarr; <strong style="color: #6aab73">ansi</strong>: The Search Service highlights matches with a yellow background
(\u001b[43m).<br><br>

&rarr; <strong style="color: #6aab73">html</strong>: The Search Service surrounds matches with
&lt;mark&gt; and&lt;/mark&gt;
HTML tags.<br><br>

</html>
8 changes: 8 additions & 0 deletions src/main/resources/docs/search/timeout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
Set the maximum time, in milliseconds, that a Search query can execute on a Search index partition.<br><br>

If the query time exceeds the <strong style="color: #6aab73">timeout</strong>, the Search Service cancels the query. The
query might return partial results if
any index partitions responded before the timeout.

</html>
4 changes: 4 additions & 0 deletions src/main/resources/docs/search/vectors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<html>
An object that contains a <strong style="color: #6aab73">{search-index-name}</strong> object for each Search index in
the query.
</html>

0 comments on commit 7407a75

Please sign in to comment.