-
Notifications
You must be signed in to change notification settings - Fork 9
/
controlled_field.sh
executable file
·84 lines (83 loc) · 1.96 KB
/
controlled_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#
# Example of matching all values of a data field to a request
#
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"controlled_fields": {
"type": "nested",
"properties": {
"controlled_field": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
'
curl -XPOST localhost:9200/test/doc/1 -d '{
"controlled_fields": [{
"controlled_field": "A"
}, {
"controlled_field": "B"
}, {
"controlled_field": "C"
}]
}
'
curl -XPOST localhost:9200/test/doc/2 -d '{
"controlled_fields": [{
"controlled_field": "X"
}, {
"controlled_field": "Y"
}, {
"controlled_field": "Z"
}]
}
'
curl -XPOST localhost:9200/test/doc/3 -d '{
"controlled_fields": [{
"controlled_field": "A"
}, {
"controlled_field": "Y"
}, {
"controlled_field": "D"
}]
}
'
curl -X POST 'http://localhost:9200/test/_refresh'
echo
curl -X GET 'http://localhost:9200/test/doc/_search?pretty' -d '{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"not": {
"nested": {
"path": "controlled_fields",
"filter": {
"not": {
"terms": {
"controlled_fields.controlled_field": ["A", "B", "D", "X", "Y"]
}
}
}
}
}
}
}
}
}
'