Add CONSOLE to span queries.

... and range, and terms...
This commit is contained in:
Isabel Drost-Fromm 2016-05-10 12:59:44 +02:00
parent 754a677ff5
commit ab4367c07e
8 changed files with 103 additions and 62 deletions

View File

@ -96,12 +96,13 @@ passing the `format` parameter to the `range` query:
-------------------------------------------------- --------------------------------------------------
GET _search GET _search
{ {
"query": "query": {
"range" : { "range" : {
"born" : { "born" : {
"gte": "01/01/2012", "gte": "01/01/2012",
"lte": "2013", "lte": "2013",
"format": "dd/MM/yyyy||yyyy" "format": "dd/MM/yyyy||yyyy"
}
} }
} }
} }

View File

@ -6,24 +6,28 @@ query maps to Lucene `SpanContainingQuery`. Here is an example:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_containing" : { "query": {
"little" : { "span_containing" : {
"span_term" : { "field1" : "foo" } "little" : {
}, "span_term" : { "field1" : "foo" }
"big" : { },
"span_near" : { "big" : {
"clauses" : [ "span_near" : {
{ "span_term" : { "field1" : "bar" } }, "clauses" : [
{ "span_term" : { "field1" : "baz" } } { "span_term" : { "field1" : "bar" } },
], { "span_term" : { "field1" : "baz" } }
"slop" : 5, ],
"in_order" : true "slop" : 5,
"in_order" : true
}
} }
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
The `big` and `little` clauses can be any span type query. Matching The `big` and `little` clauses can be any span type query. Matching
spans from `big` that contain matches from `little` are returned. spans from `big` that contain matches from `little` are returned.

View File

@ -7,24 +7,32 @@ it can be nested. Example:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_multi":{ "query": {
"match":{ "span_multi":{
"prefix" : { "user" : { "value" : "ki" } } "match":{
"prefix" : { "user" : { "value" : "ki" } }
}
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
A boost can also be associated with the query: A boost can also be associated with the query:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_multi":{ "query": {
"match":{ "span_multi":{
"prefix" : { "user" : { "value" : "ki", "boost" : 1.08 } } "match":{
"prefix" : { "user" : { "value" : "ki", "boost" : 1.08 } }
}
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE

View File

@ -8,18 +8,22 @@ matches are required to be in-order. The span near query maps to Lucene
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_near" : { "query": {
"clauses" : [ "span_near" : {
{ "span_term" : { "field" : "value1" } }, "clauses" : [
{ "span_term" : { "field" : "value2" } }, { "span_term" : { "field" : "value1" } },
{ "span_term" : { "field" : "value3" } } { "span_term" : { "field" : "value2" } },
], { "span_term" : { "field" : "value3" } }
"slop" : 12, ],
"in_order" : false "slop" : 12,
"in_order" : false
}
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
The `clauses` element is a list of one or more other span type queries The `clauses` element is a list of one or more other span type queries
and the `slop` controls the maximum number of intervening unmatched and the `slop` controls the maximum number of intervening unmatched

View File

@ -6,24 +6,28 @@ query maps to Lucene `SpanNotQuery`. Here is an example:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_not" : { "query": {
"include" : { "span_not" : {
"span_term" : { "field1" : "hoya" } "include" : {
}, "span_term" : { "field1" : "hoya" }
"exclude" : { },
"span_near" : { "exclude" : {
"clauses" : [ "span_near" : {
{ "span_term" : { "field1" : "la" } }, "clauses" : [
{ "span_term" : { "field1" : "hoya" } } { "span_term" : { "field1" : "la" } },
], { "span_term" : { "field1" : "hoya" } }
"slop" : 0, ],
"in_order" : true "slop" : 0,
"in_order" : true
}
} }
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
The `include` and `exclude` clauses can be any span type query. The The `include` and `exclude` clauses can be any span type query. The
`include` clause is the span query whose matches are filtered, and the `include` clause is the span query whose matches are filtered, and the

View File

@ -6,25 +6,37 @@ Matches spans containing a term. The span term query maps to Lucene
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_term" : { "user" : "kimchy" } "query": {
"span_term" : { "user" : "kimchy" }
}
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
A boost can also be associated with the query: A boost can also be associated with the query:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } } "query": {
"span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } }
}
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
Or : Or :
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_term" : { "user" : { "term" : "kimchy", "boost" : 2.0 } } "query": {
"span_term" : { "user" : { "term" : "kimchy", "boost" : 2.0 } }
}
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE

View File

@ -6,24 +6,28 @@ query maps to Lucene `SpanWithinQuery`. Here is an example:
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"span_within" : { "query": {
"little" : { "span_within" : {
"span_term" : { "field1" : "foo" } "little" : {
}, "span_term" : { "field1" : "foo" }
"big" : { },
"span_near" : { "big" : {
"clauses" : [ "span_near" : {
{ "span_term" : { "field1" : "bar" } }, "clauses" : [
{ "span_term" : { "field1" : "baz" } } { "span_term" : { "field1" : "bar" } },
], { "span_term" : { "field1" : "baz" } }
"slop" : 5, ],
"in_order" : true "slop" : 5,
"in_order" : true
}
} }
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
The `big` and `little` clauses can be any span type query. Matching The `big` and `little` clauses can be any span type query. Matching
spans from `little` that are enclosed within `big` are returned. spans from `little` that are enclosed within `big` are returned.

View File

@ -6,14 +6,18 @@ Filters documents that have fields that match any of the provided terms
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
GET /_search
{ {
"constant_score" : { "query": {
"filter" : { "constant_score" : {
"terms" : { "user" : ["kimchy", "elasticsearch"]} "filter" : {
"terms" : { "user" : ["kimchy", "elasticsearch"]}
}
} }
} }
} }
-------------------------------------------------- --------------------------------------------------
// CONSOLE
The `terms` query is also aliased with `in` as the filter name for The `terms` query is also aliased with `in` as the filter name for
simpler usage deprecated[5.0.0,use `terms` instead]. simpler usage deprecated[5.0.0,use `terms` instead].