Docs: CONSOLEify termvectors.asciidoc (#23046)
This commit is contained in:
parent
d45761e488
commit
e177d2ca40
|
@ -99,7 +99,6 @@ buildRestTests.expectedUnconvertedCandidates = [
|
||||||
'reference/docs/index_.asciidoc',
|
'reference/docs/index_.asciidoc',
|
||||||
'reference/docs/multi-get.asciidoc',
|
'reference/docs/multi-get.asciidoc',
|
||||||
'reference/docs/reindex.asciidoc',
|
'reference/docs/reindex.asciidoc',
|
||||||
'reference/docs/termvectors.asciidoc',
|
|
||||||
'reference/docs/update-by-query.asciidoc',
|
'reference/docs/update-by-query.asciidoc',
|
||||||
'reference/docs/update.asciidoc',
|
'reference/docs/update.asciidoc',
|
||||||
'reference/index-modules/similarity.asciidoc',
|
'reference/index-modules/similarity.asciidoc',
|
||||||
|
|
|
@ -8,16 +8,20 @@ realtime. This can be changed by setting `realtime` parameter to `false`.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true'
|
GET /twitter/tweet/1/_termvectors
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:twitter]
|
||||||
|
|
||||||
Optionally, you can specify the fields for which the information is
|
Optionally, you can specify the fields for which the information is
|
||||||
retrieved either with a parameter in the url
|
retrieved either with a parameter in the url
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?fields=text,...'
|
GET /twitter/tweet/1/_termvectors?fields=message
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[setup:twitter]
|
||||||
|
|
||||||
or by adding the requested fields in the request body (see
|
or by adding the requested fields in the request body (see
|
||||||
example below). Fields can also be specified with wildcards
|
example below). Fields can also be specified with wildcards
|
||||||
|
@ -124,8 +128,8 @@ First, we create an index that stores term vectors, payloads etc. :
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -s -XPUT 'http://localhost:9200/twitter/' -d '{
|
PUT /twitter/
|
||||||
"mappings": {
|
{ "mappings": {
|
||||||
"tweet": {
|
"tweet": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"text": {
|
"text": {
|
||||||
|
@ -160,51 +164,58 @@ curl -s -XPUT 'http://localhost:9200/twitter/' -d '{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
|
||||||
Second, we add some documents:
|
Second, we add some documents:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/1?pretty=true' -d '{
|
PUT /twitter/tweet/1
|
||||||
|
{
|
||||||
"fullname" : "John Doe",
|
"fullname" : "John Doe",
|
||||||
"text" : "twitter test test test "
|
"text" : "twitter test test test "
|
||||||
}'
|
}
|
||||||
|
|
||||||
curl -XPUT 'http://localhost:9200/twitter/tweet/2?pretty=true' -d '{
|
PUT /twitter/tweet/2
|
||||||
|
{
|
||||||
"fullname" : "Jane Doe",
|
"fullname" : "Jane Doe",
|
||||||
"text" : "Another twitter test ..."
|
"text" : "Another twitter test ..."
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[continued]
|
||||||
|
|
||||||
The following request returns all information and statistics for field
|
The following request returns all information and statistics for field
|
||||||
`text` in document `1` (John Doe):
|
`text` in document `1` (John Doe):
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
GET /twitter/tweet/1/_termvectors
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true' -d '{
|
{
|
||||||
"fields" : ["text"],
|
"fields" : ["text"],
|
||||||
"offsets" : true,
|
"offsets" : true,
|
||||||
"payloads" : true,
|
"payloads" : true,
|
||||||
"positions" : true,
|
"positions" : true,
|
||||||
"term_statistics" : true,
|
"term_statistics" : true,
|
||||||
"field_statistics" : true
|
"field_statistics" : true
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[continued]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
{
|
{
|
||||||
"_id": "1",
|
"_id": "1",
|
||||||
"_index": "twitter",
|
"_index": "twitter",
|
||||||
"_type": "tweet",
|
"_type": "tweet",
|
||||||
"_version": 1,
|
"_version": 1,
|
||||||
"found": true,
|
"found": true,
|
||||||
|
"took": 6,
|
||||||
"term_vectors": {
|
"term_vectors": {
|
||||||
"text": {
|
"text": {
|
||||||
"field_statistics": {
|
"field_statistics": {
|
||||||
|
@ -256,6 +267,9 @@ Response:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TEST[continued]
|
||||||
|
// TESTRESPONSE[s/"took": 6/"took": "$body.took"/]
|
||||||
|
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
.Generating term vectors on the fly
|
.Generating term vectors on the fly
|
||||||
|
@ -268,14 +282,17 @@ Note that for the field `text`, the terms are not re-generated.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true' -d '{
|
GET /twitter/tweet/1/_termvectors
|
||||||
|
{
|
||||||
"fields" : ["text", "some_field_without_term_vectors"],
|
"fields" : ["text", "some_field_without_term_vectors"],
|
||||||
"offsets" : true,
|
"offsets" : true,
|
||||||
"positions" : true,
|
"positions" : true,
|
||||||
"term_statistics" : true,
|
"term_statistics" : true,
|
||||||
"field_statistics" : true
|
"field_statistics" : true
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[continued]
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
[[docs-termvectors-artificial-doc]]
|
[[docs-termvectors-artificial-doc]]
|
||||||
|
@ -293,13 +310,16 @@ mapping will be dynamically created.*
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/_termvectors' -d '{
|
GET /twitter/tweet/_termvectors
|
||||||
|
{
|
||||||
"doc" : {
|
"doc" : {
|
||||||
"fullname" : "John Doe",
|
"fullname" : "John Doe",
|
||||||
"text" : "twitter test test test"
|
"text" : "twitter test test test"
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[continued]
|
||||||
--
|
--
|
||||||
|
|
||||||
[[docs-termvectors-per-field-analyzer]]
|
[[docs-termvectors-per-field-analyzer]]
|
||||||
|
@ -314,7 +334,8 @@ vectors, the term vectors will be re-generated.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
curl -XGET 'http://localhost:9200/twitter/tweet/_termvectors' -d '{
|
GET /twitter/tweet/_termvectors
|
||||||
|
{
|
||||||
"doc" : {
|
"doc" : {
|
||||||
"fullname" : "John Doe",
|
"fullname" : "John Doe",
|
||||||
"text" : "twitter test test test"
|
"text" : "twitter test test test"
|
||||||
|
@ -323,8 +344,10 @@ curl -XGET 'http://localhost:9200/twitter/tweet/_termvectors' -d '{
|
||||||
"per_field_analyzer" : {
|
"per_field_analyzer" : {
|
||||||
"fullname": "keyword"
|
"fullname": "keyword"
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[continued]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
|
@ -335,12 +358,13 @@ Response:
|
||||||
"_type": "tweet",
|
"_type": "tweet",
|
||||||
"_version": 0,
|
"_version": 0,
|
||||||
"found": true,
|
"found": true,
|
||||||
|
"took": 6,
|
||||||
"term_vectors": {
|
"term_vectors": {
|
||||||
"fullname": {
|
"fullname": {
|
||||||
"field_statistics": {
|
"field_statistics": {
|
||||||
"sum_doc_freq": 1,
|
"sum_doc_freq": 2,
|
||||||
"doc_count": 1,
|
"doc_count": 4,
|
||||||
"sum_ttf": 1
|
"sum_ttf": 4
|
||||||
},
|
},
|
||||||
"terms": {
|
"terms": {
|
||||||
"John Doe": {
|
"John Doe": {
|
||||||
|
@ -358,6 +382,11 @@ Response:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TEST[continued]
|
||||||
|
// TESTRESPONSE[s/"took": 6/"took": "$body.took"/]
|
||||||
|
// TESTRESPONSE[s/"sum_doc_freq": 2/"sum_doc_freq": "$body.term_vectors.fullname.field_statistics.sum_doc_freq"/]
|
||||||
|
// TESTRESPONSE[s/"doc_count": 4/"doc_count": "$body.term_vectors.fullname.field_statistics.doc_count"/]
|
||||||
|
// TESTRESPONSE[s/"sum_ttf": 4/"sum_ttf": "$body.term_vectors.fullname.field_statistics.sum_ttf"/]
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
[[docs-termvectors-terms-filtering]]
|
[[docs-termvectors-terms-filtering]]
|
||||||
|
@ -388,6 +417,8 @@ GET /imdb/movies/_termvectors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// CONSOLE
|
||||||
|
// TEST[skip:no imdb test index]
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
|
@ -429,4 +460,5 @@ Response:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
// TESTRESPONSE
|
||||||
==================================================
|
==================================================
|
||||||
|
|
Loading…
Reference in New Issue