-
Notifications
You must be signed in to change notification settings - Fork 9
/
multi_match.sh
executable file
·62 lines (61 loc) · 1.63 KB
/
multi_match.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
55
56
57
58
59
60
61
#!/bin/bash
#
# This script demonstrates usage of multi_field with mutli_match
#
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"doc": {
"properties": {
"subject": {
"type": "multi_field",
"fields": {
"fulltext": { "type": "string", "index": "analyzed" },
"subject": { "type": "string", "index": "not_analyzed" }
}
},
"message": {
"type": "multi_field",
"fields": {
"fulltext": { "type": "string", "index": "analyzed" },
"message": { "type": "string", "index": "not_analyzed" }
}
}
}
}
}
}
'
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
"subject": "elasticsearch",
"message": "You know, for search"
}'
curl -XPUT localhost:9200/test-idx/doc/2 -d '{
"subject": "The Hudsucker Proxy",
"message": "You know, for kids"
}'
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/_search?pretty=true" -d '{
"query": {
"multi_match" : {
"query" : "know",
"fields" : [ "*.fulltext"]
}
}
}
'
echo
curl "localhost:9200/test-idx/_validate/query?pretty=true&explain=true" -d '{
"multi_match" : {
"query" : "know",
"fields" : [ "*.fulltext"]
}
}
'