Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify context suggestions filtering and boosting #33601

Merged
merged 1 commit into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions docs/reference/search/suggesters/context-suggest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Every context mapping has a unique name and a type. There are two types: `catego
and `geo`. Context mappings are configured under the `contexts` parameter in
the field mapping.

NOTE: It is mandatory to provide a context when indexing and querying
a context enabled completion field.

The following defines types, each with two context mappings for a completion
field:

Expand Down Expand Up @@ -84,10 +87,6 @@ PUT place_path_category
NOTE: Adding context mappings increases the index size for completion field. The completion index
is entirely heap resident, you can monitor the completion field index size using <<indices-stats>>.

NOTE: deprecated[7.0.0, Indexing a suggestion without context on a context enabled completion field is deprecated
and will be removed in the next major release. If you want to index a suggestion that matches all contexts you should
add a special context for it.]

[[suggester-context-category]]
[float]
==== Category Context
Expand Down Expand Up @@ -160,9 +159,9 @@ POST place/_search?pretty
// CONSOLE
// TEST[continued]

Note: deprecated[7.0.0, When no categories are provided at query-time, all indexed documents are considered.
Querying with no categories on a category enabled completion field is deprecated and will be removed in the next major release
as it degrades search performance considerably.]
NOTE: If multiple categories or category contexts are set on the query
they are merged as a disjunction. This means that suggestions match
if they contain at least one of the provided context values.

Suggestions with certain categories can be boosted higher than others.
The following filters suggestions by categories and additionally boosts
Expand Down Expand Up @@ -218,6 +217,9 @@ multiple category context clauses. The following parameters are supported for a
so on, by specifying a category prefix of 'type'.
Defaults to `false`

NOTE: If a suggestion entry matches multiple contexts the final score is computed as the
maximum score produced by any matching contexts.

[[suggester-context-geo]]
[float]
==== Geo location Context
Expand Down Expand Up @@ -307,6 +309,10 @@ POST place/_search
NOTE: When a location with a lower precision at query time is specified, all suggestions
that fall within the area will be considered.

NOTE: If multiple categories or category contexts are set on the query
they are merged as a disjunction. This means that suggestions match
if they contain at least one of the provided context values.

Suggestions that are within an area represented by a geohash can also be boosted higher
than others, as shown by the following:

Expand Down Expand Up @@ -349,6 +355,9 @@ POST place/_search?pretty
that fall under the geohash representation of '(43.6624803, -79.3863353)'
with a default precision of '6' by a factor of `2`

NOTE: If a suggestion entry matches multiple contexts the final score is computed as the
maximum score produced by any matching contexts.

In addition to accepting context values, a context query can be composed of
multiple context clauses. The following parameters are supported for a
`category` context clause:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ public void testMultiContextFiltering() throws Exception {
assertSuggestions("foo", typeFilterSuggest, "suggestion9", "suggestion6", "suggestion5", "suggestion2", "suggestion1");
}

@AwaitsFix(bugUrl = "multiple context boosting is broken, as a suggestion, contexts pair is treated as (num(context) entries)")
public void testMultiContextBoosting() throws Exception {
LinkedHashMap<String, ContextMapping<?>> map = new LinkedHashMap<>();
map.put("cat", ContextBuilder.category("cat").field("cat").build());
Expand Down Expand Up @@ -328,7 +327,8 @@ public void testMultiContextBoosting() throws Exception {
CategoryQueryContext.builder().setCategory("cat1").build())
);
multiContextBoostSuggest.contexts(contextMap);
assertSuggestions("foo", multiContextBoostSuggest, "suggestion9", "suggestion6", "suggestion5", "suggestion2", "suggestion1");
// the score of each suggestion is the maximum score among the matching contexts
assertSuggestions("foo", multiContextBoostSuggest, "suggestion9", "suggestion8", "suggestion5", "suggestion6", "suggestion4");
}

public void testSeveralContexts() throws Exception {
Expand Down