Skip to content

Instantly share code, notes, and snippets.

@aoeuidht
Created October 22, 2014 06:21
Show Gist options
  • Save aoeuidht/90958a7af7ddfe44171e to your computer and use it in GitHub Desktop.
Save aoeuidht/90958a7af7ddfe44171e to your computer and use it in GitHub Desktop.
#48 issues
1. print query out at search/views.py
s = s.query_raw(query)
print jsond.dumps(query)
then we got:
```
{"bool": {"minimum_should_match": 1, "should": [{"bool": {"must": [{"multi_match": {"fields": ["item_name_standard_analyzed^1000", "brand_name^100", "tags_standard^10", "description"], "type": "phrase", "query": "\u667a\u591a\u661f"}}]}}, {"match": {"item_spec_ng": "\u667a\u591a\u661f"}}, {"term": {"sku": "\u667a\u591a\u661f"}}, {"match": {"stick_key": {"query": "\u667a\u591a\u661f", "boost": "10000"}}}]}}
```
and this search return only 1 item in python
2. use the query dumped, send it to es directly:
curl "127.0.0.1:9200/item-index-v4-site_for_tests/_search?size=10" -d '{"query": {"bool": {"minimum_should_match": 1, "should": [{"bool": {"must": [{"multi_match": {"fields": ["item_name_standard_analyzed^1000", "brand_name^100", "tags_standard^10", "description"], "type": "phrase", "query": "\u667a\u591a\u661f"}}]}}, {"match": {"item_spec_ng": "\u667a\u591a\u661f"}}, {"term": {"sku": "\u667a\u591a\u661f"}}, {"match": {"stick_key": {"query": "\u667a\u591a\u661f", "boost": "10000"}}}]}}}'
and I can got 2 results
```
"hits":{"total":2,"max_score":0.7598721,"hits":[{"_index":"item-index-v4-site_for_tests",
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment