Commit graph

29 commits

Author SHA1 Message Date
Liam Thompson
7b39d3db52
Term Stats documentation (#115933) (#116167)
* Term Stats documentation

* Update docs/reference/reranking/learning-to-rank-model-training.asciidoc

Co-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>

* Fix query example.

---------

Co-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>
(cherry picked from commit 0416812456)

Co-authored-by: Aurélien FOUCRET <aurelien.foucret@gmail.com>
2024-11-04 23:28:12 +11:00
Liam Thompson
33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00
Abdon Pijpelink
7d01d768c2
[DOCS] Warn about calling vector functions repeatedly (#91864)
* [DOCS] Add script score vector function clarification

* [DOCS] Warn about calling vector functions repeatedly
2022-12-12 09:43:46 +01:00
Mayya Sharipova
1ae209335d
Undeprecate function_score query (#87807)
We had a plan to deprecate function_score query with
script_score query, but ran into a roadblock of missing
functionality to combine scores from different
functions (particularly "first" script_score).
Wee have several proposal to address this missing
functionality:
 [scripted_boolean](https://github.com/elastic/elasticsearch/issues/27588#issuecomment-444887726)
 [compound_query](https://github.com/elastic/elasticsearch/issues/51967)
 [first_query](https://github.com/elastic/elasticsearch/issues/52482)

But for now, we decided not to deprecate function_score query,
and hence we need to remove any mention that we are deprecating it.

Relates to #42811
Closes #71934
2022-06-17 11:04:26 -04:00
James Rodewig
a4dc336c16
[DOCS] Replace twitter dataset in search/agg docs (#60667) 2020-08-04 13:31:52 -04:00
James Rodewig
80b674fb25
[DOCS] Reformat snippets to use two-space indents (#59973) 2020-07-21 12:24:26 -04:00
Mayya Sharipova
556ee9a719
Correct boost calculation in script_score query (#52478)
Before boost in script_score query was wrongly applied only to the subquery.
This commit makes sure that the boost is applied to the whole score
that comes out of script.

Closes #48465
2020-02-24 10:46:33 -05:00
Marios Trivyzas
a8b39ed842
Add a cluster setting to disallow expensive queries (#51385)
Add a new cluster setting `search.allow_expensive_queries` which by
default is `true`. If set to `false`, certain queries that have 
usually slow performance cannot be executed and an error message
is returned.

- Queries that need to do linear scans to identify matches:
  - Script queries
- Queries that have a high up-front cost:
  - Fuzzy queries
  - Regexp queries
  - Prefix queries (without index_prefixes enabled
  - Wildcard queries
  - Range queries on text and keyword fields
- Joining queries
  - HasParent queries
  - HasChild queries
  - ParentId queries
  - Nested queries
- Queries on deprecated 6.x geo shapes (using PrefixTree implementation)
- Queries that may have a high per-document cost:
  - Script score queries
  - Percolate queries

Closes: #29050
2020-02-12 18:06:04 +01:00
Orhan Toy
0db416921c [DOCS] Fix missing quote in script-score-query.asciidoc (#50590) 2020-01-03 16:15:18 +01:00
Ryan Ernst
d8b4556e2d
Add explanations to script score queries (#46693)
While function scores using scripts do allow explanations, they are only
creatable with an expert plugin. This commit improves the situation for
the newer script score query by adding the ability to set the
explanation from the script itself.

To set the explanation, a user would check for `explanation != null` to
indicate an explanation is needed, and then call
`explanation.set("some description")`.
2019-10-03 19:35:59 -07:00
James Rodewig
5c78f606c2
[DOCS] Change // CONSOLE comments to [source,console] (#46440) 2019-09-09 10:45:37 -04:00
James Rodewig
e1fe213d8f
[DOCS] Reformat script score query (#45087) 2019-08-01 12:06:34 -04:00
James Rodewig
ec37a9cea0
[DOCS] Make Query DSL titles consistent (#43935) 2019-07-18 10:18:11 -04:00
Mayya Sharipova
16747f811f
Add l1norm and l2norm distances for vectors (#44116)
* Add l1norm and l2norm distances for vectors

Add L1norm - Manhattan distance
Add L2norm - Euclidean distance
relates to #37947

* Address Christoph's feedback

- organize vector functions as a separate doc
- increase precision in tests calculations
- add a separate test when sparse doc dims
are bigger and less than query vector dims

* Made examples more realistic
2019-07-11 14:14:23 -04:00
Mayya Sharipova
5255eb3c77
Forbid empty doc values on vector functions (#43944)
Currently when a document misses a vector value, vector function
returns 0 as a score for this document. We think this is incorrect
behaviour.
With this change, an error will be thrown if vector functions are
used with docs that are missing vector doc values.
Also VectorScriptDocValues is modified to allow size() function,
which can be used to check if a document has a value for the
vector field.
2019-07-05 17:59:13 -04:00
Mayya Sharipova
66e1e5643f
Add dims parameter to dense_vector mapping (#43444)
Typically, dense vectors of both documents and queries must have the same
number of dimensions. Different number of dimensions among documents
or query vector indicate an error. This PR enforces that all vectors
for the same field have the same number of dimensions. It also enforces
that query vectors have the same number of dimensions.
2019-07-02 16:21:10 -04:00
Mayya Sharipova
952ddf247a
Move dense_vector and sparse_vector to module (#43280) 2019-06-18 08:15:46 -04:00
Mayya Sharipova
6f8dfeb6b5
Add experimental and warnings to vector functions (#42205) 2019-05-21 06:36:38 -04:00
James Rodewig
adf67053f4
[DOCS] Add anchors for Asciidoctor migration (#41648) 2019-04-30 10:19:09 -04:00
Mayya Sharipova
29701b0229
Remove experimental label froms script_score query (#41572) 2019-04-26 08:50:27 -04:00
James Rodewig
391ac5a709
[DOCS] Fix callout for Asciidoctor migration (#41129) 2019-04-11 15:46:13 -04:00
Julie Tibshirani
5901b4286e
Update vector similarity examples to avoid negative scores. (#40493)
Negative scores are no longer allowed, but the cosine similarity between two
vectors lies in the range [-1, 1], and dot products can also be negative. This commit
updates the documentation with an example of how to avoid negative scores.
2019-03-29 11:29:54 -07:00
Mayya Sharipova
459715dba7
Add randomScore function in script_score query (#40186)
To make script_score query to have the same features
as function_score query, we need to add randomScore
function.

This function produces different
random scores on different index shards.
It is also able to produce random scores
based on the internal Lucene Document Ids.
2019-03-28 11:29:29 -04:00
Mayya Sharipova
3260fd1fc8
Distance measures for dense and sparse vectors (#37947)
* Distance measures for dense and sparse vectors

Introduce painless functions of
cosineSimilarity and dotProduct distance
measures for dense and sparse vector fields.

```js
{
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      },
      "script": {
        "source": "cosineSimilarity(params.queryVector, doc['my_dense_vector'].value)",
        "params": {
          "queryVector": [4, 3.4, -1.2]
        }
      }
    }
  }
}
```

```js
{
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      },
      "script": {
        "source": "cosineSimilaritySparse(params.queryVector, doc['my_sparse_vector'].value)",
        "params": {
          "queryVector": {"2": -0.5, "10" : 111.3, "50": -13.0, "113": 14.8, "4545": -156.0}
        }
      }
    }
  }
}
```

Closes #31615
2019-02-20 07:01:17 -05:00
Mayya Sharipova
a30ce6a00a
Rename feature, feature_vector and feature_query (#37794)
Ranaming as follows:
feature -> rank_feature
feature_vector -> rank_features
feature query -> rank_feature query

Ranaming is done to distinguish from other vector types.

Closes #36723
2019-01-24 19:18:48 -05:00
Mayya Sharipova
fdb66039d4
Change rational to saturation in script_score (#37766)
This change of the function name is necessary for conformity
with feature queries.

Closes #37714
2019-01-23 14:28:20 -05:00
Mayya Sharipova
942fc13af5
Use plain text instead of latexmath
As latexmath is not rendered, using plain text instead

Closes #37718
2019-01-22 16:49:03 -05:00
Jim Ferenczi
667c06dc83 Add link to script score query in the top level docs (#36416)
* add link to script score query in the top level docs

* Correct references in script-score-query.asciidoc
2018-12-19 10:18:53 -05:00
Mayya Sharipova
643bb20137
Add a new query type - ScriptScoreQuery (#34533)
* Add a new query type - ScriptScoreQuery

script_score query uses script to calculate document scores.
Added as a substitute for function_score with an intentation
to deprecate function_scoreq query.

```http
GET /_search
{
    "query": {
        "script_score" : {
            "query": {
                "match": { "message": "elasticsearch" }
            },
            "script" : {
              "source": "Math.log(2 + doc['likes'].value)"
            },
            "min_score" : 2
        }
    }
}
```

Add several functions to painless to be used inside script_score:

double rational(double, double)
double sigmoid(double, double, double)
double randomNotReproducible() 
double randomReproducible(String, int) 

double decayGeoLinear(String, String, String, double, GeoPoint)
double decayGeoExp(String, String, String, double, GeoPoint)
double decayGeoGauss(String, String, String, double, GeoPoint)

double decayNumericLinear(String, String, String, double, double)
double decayNumericExp(String, String, String, double, double)
double decayNumericGauss(String, String, String, double, double)

double decayDateLinear(String, String, String, double, JodaCompatibleZonedDateTime)
double decayDateExp(String, String, String, double, JodaCompatibleZonedDateTime)
double decayDateGauss(String, String, String, double, JodaCompatibleZonedDateTime)

Date functions only works on dates in  the default format and default time zone
2018-11-20 16:10:06 -05:00