You have this query:
{
"query": {
"term": {
"keywordField": {
"value": "Geller"
}
}
}
}
And these documents:
- keywordField: "Joey"
- keywordField: "Rachel Green-Geller"
- keywordField: "Ross Geller"
- keywordField: "Monica geller Bing"
- keywordField: "Chandler Bing"
- keywordField: "Gunther hates Ross Gellerrr"
What document/s would be returned?
. . . . .
(Answer: 0. Why? term
+ keywordField
looks for an EXACT MATCH. Just matching 1 word isn't enough).
You have this query:
{
"query": {
"term": {
"textField": {
"value": "Geller"
}
}
}
}
And these documents:
- textField: "Joey"
- textField: "Rachel Green-Geller"
- textField: "Ross Geller"
- textField: "Monica geller Bing"
- textField: "Chandler Bing"
- textField: "Gunther hates Ross Gellerrr"
What document/s would be returned?
Before we answer question 2, let's move on to question 3.
. . . . .
(Answer: 0. Why? term
+ textField
takes the field's value, lowercases it, and then checks the provided value against it. The provided value stays AS-IS! Which means that if it contains an uppercase letter, there's a 0 percent chance for a match).
You have this query:
{
"query": {
"term": {
"textField": {
"value": "geller"
}
}
}
}
And these documents:
- textField: "Joey"
- textField: "Rachel Green-Geller"
- textField: "Ross Geller"
- textField: "Monica geller Bing"
- textField: "Chandler Bing"
- textField: "Gunther hates Ross Gellerrr"
What document/s would be returned?
. . . . .
(Answer: 3 documents overall. Documents 2, 3 ad 4. But not 6. Why? term
+ textField
takes the field's value, lowercases it, and then checks the provided value against it. The provided value stays AS-IS! Which means that if it contains an uppercase letter, there's a 0 percent chance for a match).
You have this query:
{
"query": {
"term": {
"textAndKeywordField": {
"value": "bing"
}
}
}
}
And these documents:
- textField: "Joey"
- textField: "Rachel Green-Geller"
- textField: "Ross Geller"
- textField: "Monica geller Bing"
- textField: "Chandler Bing"
- textField: "Gunther hates Ross Gellerrr"
What document/s would be returned?
. . . . .
(Answer: 2. Why? Because by default term
+ textAndKeywordField
considers the field as of text
type. And when it is text type, we already know what happens - text
type is being processed, which means everything is lowercased, "Bing" becomes "bing", and then the compare gives us a match).
You have this query:
{
"query": {
"term": {
"textAndKeywordField": {
"value": "Joey.keyword" // before that, ask about "Joey"
}
}
}
}
And these documents:
- textField: "Joey"
- textField: "Rachel Green-Geller"
- textField: "Ross Geller"
- textField: "Monica geller Bing"
- textField: "Chandler Bing"
- textField: "Gunther hates Ross Gellerrr"
What document/s would be returned?
. . . . .
(Answer: 0. Why? Because this is a trick question. The ".keyword" is on the wrong section. It should be on the fieldName
).
You have this query:
{
"query": {
"term": {
"booleanField": 0
}
}
}
And these documents:
- 3 documents with
true
- 2 documents with
false
- 1 document doesn't have the field
booleanField
How many document/s would return?
. . . . .
(Answer: 0. Why? Because this is a trick question. The ".keyword" is on the wrong section. It should be on the fieldName
).
You have this query:
{
"query": {
"term": {
"dateField": 585111111111
}
}
}
And these documents:
- Monica has "dateField" : "585111111111"
- Joey has "dateField" : 585111111111
- Rachel has "dateField" : "1988-07-17T02:51:51.111Z"
What document/s would return?
. . . . .
(Answer: All 3 of them.).
You have this query:
{
"query": {
"term": {
"numberField": {
"value":"5"
}
}
}
}
And these documents:
- Two documents with value of 5 for "numberField"
What document/s would return?
. . . . .
(Answer: Both of them.).