-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmulti_field.sh
executable file
·54 lines (44 loc) · 1.01 KB
/
multi_field.sh
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
#!/bin/sh
alias curl='./curl_wrapper.rb'
curl -s -XDELETE localhost:9200/test > /dev/null
curl -XPOST localhost:9200/test -d '{
"mappings": {
"order": {
"properties": {
"reference": {
"type": "multi_field",
"fields": {
"reference": { "type": "string", "index": "analyzed" },
"unanalyzed": { "type": "string", "index": "not_analyzed" }
}
}
}
}
}
}'
curl -XPUT localhost:9200/test/order/1 -d '{
"reference": "123-456"
}'
curl -XPOST localhost:9200/test/_refresh
curl localhost:9200/test/order/_search?pretty=true -d '{
"query": {
"text": {
"reference": "456-123"
}
}
}' # hit
curl localhost:9200/test/order/_search?pretty=true -d '{
"query": {
"text": {
"reference.unanalyzed": "456-123"
}
}
}' # miss
curl localhost:9200/test/order/_search?pretty=true -d '{
"query": {
"text": {
"reference.unanalyzed": "123-456"
}
}
}' # hit
curl -s -XDELETE localhost:9200/test > /dev/null