This repository was archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy path05_Term_text.json
76 lines (68 loc) · 1.53 KB
/
05_Term_text.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Delete the `my_store` index
DELETE /my_store
# Index example docs
POST /my_store/products/_bulk
{"index":{"_id":1}}
{"price":10,"productID":"XHDK-A-1293-#fJ3"}
{"index":{"_id":2}}
{"price":20,"productID":"KDKE-B-9947-#kL5"}
{"index":{"_id":3}}
{"price":30,"productID":"JODL-X-1937-#pV7"}
{"index":{"_id":4}}
{"price":30,"productID":"QQPX-R-3956-#aD8"}
# Term filter with text - no results!
GET /my_store/products/_search
{
"query": {
"bool": {
"filter": {
"term": {
"productID": "XHDK-A-1293-#fJ3"
}
}
}
}
}
# Test analysis of productID field
GET /my_store/_analyze?field=productID&text=XHDK-A-1293-%23fJ3
# Delete the `my_store` index
DELETE /my_store
# Map the `productID` field to be an "exact value"
PUT /my_store
{
"mappings": {
"products": {
"properties": {
"productID": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
# Test analysis of productID field
GET /my_store/_analyze?field=productID&text=XHDK-A-1293-%23fJ3
# Index example docs
POST /my_store/products/_bulk
{"index":{"_id":1}}
{"price":10,"productID":"XHDK-A-1293-#fJ3"}
{"index":{"_id":2}}
{"price":20,"productID":"KDKE-B-9947-#kL5"}
{"index":{"_id":3}}
{"price":30,"productID":"JODL-X-1937-#pV7"}
{"index":{"_id":4}}
{"price":30,"productID":"QQPX-R-3956-#aD8"}
# Term filter with text - no results!
GET /my_store/products/_search
{
"query": {
"bool": {
"filter": {
"term": {
"productID": "XHDK-A-1293-#fJ3"
}
}
}
}
}