-
-
Save max-inetgiant/9fb4789935b2bc73e772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'http://10.0.10.223:9200/testparentfacets/' && echo | |
curl -XPUT 'http://10.0.10.223:9200/testparentfacets/' -d ' | |
{ | |
"settings":{ | |
"number_of_shards":5, | |
"number_of_replicas":1, | |
"analysis":{ | |
"analyzer":{ | |
"stem":{ | |
"tokenizer":"standard", | |
"filter":[ | |
"standard", | |
"lowercase", | |
"stop", | |
"porter_stem" | |
], | |
"stopwords_path":"products_stopwords.txt" | |
} | |
} | |
} | |
}, | |
"mappings":{ | |
"product": { | |
"_parent": { | |
"type": "group" | |
}, | |
"_routing": { | |
"required": true | |
}, | |
"properties": { | |
"base_topic": { | |
"type": "integer" | |
}, | |
"categories": { | |
"type": "string", | |
"analyzer": "stem" | |
}, | |
"date": { | |
"type": "integer" | |
}, | |
"description": { | |
"type": "string", | |
"analyzer": "stem" | |
}, | |
"facet_age": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_brand": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_color": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_manufacturer": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_material": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_size": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facet_weight": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"facets": { | |
"type": "string", | |
"analyzer": "stem" | |
}, | |
"hash": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"hidden": { | |
"type": "string", | |
"analyzer": "stem" | |
}, | |
"id_country": { | |
"type": "integer" | |
}, | |
"keywords": { | |
"type": "string", | |
"analyzer": "stem" | |
}, | |
"location": { | |
"type": "geo_point" | |
}, | |
"number_sku": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"number_upc": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"owner": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"owner_file": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
}, | |
"price": { | |
"type": "float" | |
}, | |
"title": { | |
"type": "string", | |
"analyzer": "stem" | |
} | |
} | |
}, | |
"group": { | |
"properties": { | |
"hash": { | |
"type": "string", | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"index_options": "docs" | |
} | |
} | |
} | |
} | |
} | |
' && echo | |
sleep 1 | |
curl -XPUT 'http://10.0.10.223:9200/testparentfacets/group/64a4c4d0cf3ab7bb17e0ba62e7e201cd' -d '{"hash":"64a4c4d0cf3ab7bb17e0ba62e7e201cd"}' && echo | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/product/bca1efe0cd89dc42bfc913f098b67bf3?parent=64a4c4d0cf3ab7bb17e0ba62e7e201cd' -d ' | |
{ | |
"title": "Infiniti QX60 2014 Base AWD 4dr SUV G AWD CVT", | |
"description": "Warranty\nAWD 4dr SUV \nSUV \n4 Doors \nV6 \n3.50L \nGas \n", | |
"hidden": "", | |
"keywords": "", | |
"categories": "", | |
"facets": "Infiniti Tan", | |
"facet_brand": "", | |
"facet_manufacturer": "Infiniti", | |
"facet_material": "", | |
"facet_color": "Tan", | |
"facet_size": "", | |
"facet_weight": "", | |
"facet_age": "", | |
"number_upc": "", | |
"number_sku": "", | |
"hash": "bca1efe0cd89dc42bfc913f098b67bf3", | |
"owner": "Greenwich infiniti", | |
"owner_file": "detroittrading.net", | |
"price": "57435", | |
"id_country": 1, | |
"base_topic": 2, | |
"date": 1377792000, | |
"location": { | |
"lat": "41.023273", | |
"lon": "-73.623161" | |
} | |
} | |
' && echo | |
curl -XPUT 'http://10.0.10.223:9200/testparentfacets/group/24237bb1791edbfdf349f9ffcbcaea13' -d '{"hash":"24237bb1791edbfdf349f9ffcbcaea13"}' && echo | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/product/f047b7225daa8dd2ab6258f9fed9a3e1?parent=24237bb1791edbfdf349f9ffcbcaea13' -d ' | |
{ | |
"title": "Infiniti QX60 2014 Base AWD 4dr SUV Diamond Slate G AWD CVT", | |
"description": "AWD 4dr SUV \nSUV \n4 Doors \nV6 \n3.50L \nGas \n", | |
"hidden": "", | |
"keywords": "", | |
"categories": "", | |
"facets": "Infiniti Graphite", | |
"facet_brand": "", | |
"facet_manufacturer": "Infiniti", | |
"facet_material": "", | |
"facet_color": "Graphite", | |
"facet_size": "", | |
"facet_weight": "", | |
"facet_age": "", | |
"number_upc": "", | |
"number_sku": "", | |
"hash": "f047b7225daa8dd2ab6258f9fed9a3e1", | |
"owner": "Pepe infiniti", | |
"owner_file": "detroittrading.net", | |
"price": "55575", | |
"id_country": 1, | |
"base_topic": 2, | |
"date": 1377792000, | |
"location": { | |
"lat": "41.034805", | |
"lon": "-73.783661" | |
} | |
} | |
' && echo | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/_refresh' && echo | |
# {"ok":true,"acknowledged":true} | |
# {"ok":true,"acknowledged":true} | |
# {"ok":true,"_index":"testparentfacets","_type":"group","_id":"64a4c4d0cf3ab7bb17e0ba62e7e201cd","_version":1} | |
# {"ok":true,"_index":"testparentfacets","_type":"product","_id":"bca1efe0cd89dc42bfc913f098b67bf3","_version":1} | |
# {"ok":true,"_index":"testparentfacets","_type":"group","_id":"24237bb1791edbfdf349f9ffcbcaea13","_version":1} | |
# {"ok":true,"_index":"testparentfacets","_type":"product","_id":"f047b7225daa8dd2ab6258f9fed9a3e1","_version":1} | |
# {"ok":true,"_shards":{"total":4,"successful":4,"failed":0}} | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/_search?pretty=true' -d ' | |
{ | |
"sort": [ | |
{ | |
"_geo_distance": { | |
"location": { | |
"lat": 40.6234, | |
"lon": -74.0288 | |
}, | |
"order": "asc", | |
"unit": "km" | |
} | |
} | |
], | |
"fields": [], | |
"query": { | |
"has_child": { | |
"score_type": "max", | |
"type": "product", | |
"query": { | |
"custom_filters_score": { | |
"query": { | |
"filtered": { | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"multi_match": { | |
"query": "Infiniti", | |
"fields": [ | |
"title", | |
"description", | |
"facets", | |
"keywords", | |
"categories", | |
"hidden" | |
], | |
"operator": "and", | |
"use_dis_max": false | |
} | |
} | |
], | |
"should": [] | |
} | |
}, | |
"filter": { | |
"and": [ | |
{ | |
"bool": { | |
"must": [ | |
{ | |
"terms": { | |
"base_topic": [ | |
"1", | |
"2", | |
"597820", | |
"599660", | |
"599661", | |
"5256322", | |
"599666", | |
"1753836", | |
"599667", | |
"599669", | |
"5240682", | |
"599662", | |
"5240666", | |
"599668", | |
"5240672", | |
"5326625", | |
"5256324", | |
"599663", | |
"5240669", | |
"599665", | |
"1753835" | |
] | |
} | |
}, | |
{ | |
"term": { | |
"id_country": 1 | |
} | |
}, | |
{ | |
"range": { | |
"date": { | |
"from": 1376938800 | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"or": [ | |
{ | |
"geo_distance": { | |
"distance": "100km", | |
"location": { | |
"lat": 40.6234, | |
"lon": -74.0288 | |
} | |
} | |
}, | |
{ | |
"missing": { | |
"field": "location" | |
} | |
} | |
] | |
} | |
] | |
} | |
} | |
}, | |
"filters": [], | |
"score_mode": "total" | |
} | |
} | |
} | |
}, | |
"from": 0, | |
"size": 60 | |
} | |
' && echo | |
# { | |
# "took" : 2, | |
# "timed_out" : false, | |
# "_shards" : { | |
# "total" : 2, | |
# "successful" : 2, | |
# "failed" : 0 | |
# }, | |
# "hits" : { | |
# "total" : 2, | |
# "max_score" : null, | |
# "hits" : [ { | |
# "_index" : "testparentfacets", | |
# "_type" : "group", | |
# "_id" : "64a4c4d0cf3ab7bb17e0ba62e7e201cd", | |
# "_score" : null, | |
# "sort" : [ 1.7976931348623157E308 ] | |
# }, { | |
# "_index" : "testparentfacets", | |
# "_type" : "group", | |
# "_id" : "24237bb1791edbfdf349f9ffcbcaea13", | |
# "_score" : null, | |
# "sort" : [ 1.7976931348623157E308 ] | |
# } ] | |
# } | |
# } | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/_search?pretty=true' -d ' | |
{ | |
"sort": [ | |
{ | |
"_geo_distance": { | |
"location": { | |
"lat": 40.6234, | |
"lon": -74.0288 | |
}, | |
"order": "asc", | |
"unit": "km" | |
} | |
} | |
], | |
"fields": [], | |
"query": { | |
"custom_filters_score": { | |
"query": { | |
"filtered": { | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"multi_match": { | |
"query": "Infiniti", | |
"fields": [ | |
"title", | |
"description", | |
"facets", | |
"keywords", | |
"categories", | |
"hidden" | |
], | |
"operator": "and", | |
"use_dis_max": false | |
} | |
} | |
], | |
"should": [] | |
} | |
}, | |
"filter": { | |
"and": [ | |
{ | |
"bool": { | |
"must": [ | |
{ | |
"terms": { | |
"base_topic": [ | |
"1", | |
"2", | |
"597820", | |
"599660", | |
"599661", | |
"5256322", | |
"599666", | |
"1753836", | |
"599667", | |
"599669", | |
"5240682", | |
"599662", | |
"5240666", | |
"599668", | |
"5240672", | |
"5326625", | |
"5256324", | |
"599663", | |
"5240669", | |
"599665", | |
"1753835" | |
] | |
} | |
}, | |
{ | |
"term": { | |
"id_country": 1 | |
} | |
}, | |
{ | |
"range": { | |
"date": { | |
"from": 1376938800 | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"or": [ | |
{ | |
"geo_distance": { | |
"distance": "100km", | |
"location": { | |
"lat": 40.6234, | |
"lon": -74.0288 | |
} | |
} | |
}, | |
{ | |
"missing": { | |
"field": "location" | |
} | |
} | |
] | |
} | |
] | |
} | |
} | |
}, | |
"filters": [], | |
"score_mode": "total" | |
} | |
}, | |
"from": 0, | |
"size": 60 | |
} | |
' && echo | |
# { | |
# "took" : 1, | |
# "timed_out" : false, | |
# "_shards" : { | |
# "total" : 2, | |
# "successful" : 2, | |
# "failed" : 0 | |
# }, | |
# "hits" : { | |
# "total" : 2, | |
# "max_score" : null, | |
# "hits" : [ { | |
# "_index" : "testparentfacets", | |
# "_type" : "product", | |
# "_id" : "f047b7225daa8dd2ab6258f9fed9a3e1", | |
# "_score" : null, | |
# "sort" : [ 50.236949738919485 ] | |
# }, { | |
# "_index" : "testparentfacets", | |
# "_type" : "product", | |
# "_id" : "bca1efe0cd89dc42bfc913f098b67bf3", | |
# "_score" : null, | |
# "sort" : [ 56.1165820505235 ] | |
# } ] | |
# } | |
# } | |
curl -XPOST 'http://10.0.10.223:9200/testparentfacets/_search?pretty=true' -d ' | |
{ | |
"fields": [], | |
"query": { | |
"has_child": { | |
"score_type": "max", | |
"type": "product", | |
"query": { | |
"custom_score": { | |
"query": { | |
"match_all": {} | |
}, | |
"script": "doc[\"location\"].distance(40.6234, -74.0288)" | |
} | |
} | |
} | |
} | |
} | |
' && echo | |
# { | |
# "took" : 2, | |
# "timed_out" : false, | |
# "_shards" : { | |
# "total" : 5, | |
# "successful" : 5, | |
# "failed" : 0 | |
# }, | |
# "hits" : { | |
# "total" : 2, | |
# "max_score" : 39.39948, | |
# "hits" : [ { | |
# "_index" : "testparentfacets", | |
# "_type" : "group", | |
# "_id" : "64a4c4d0cf3ab7bb17e0ba62e7e201cd", | |
# "_score" : 39.39948 | |
# }, { | |
# "_index" : "testparentfacets", | |
# "_type" : "group", | |
# "_id" : "24237bb1791edbfdf349f9ffcbcaea13", | |
# "_score" : 33.126003 | |
# } ] | |
# } | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment