2
這是一個簡單的彈性工作搜索查詢。我必須使用彈性搜索dsl模塊將其轉換爲python代碼。將彈性搜索查詢轉換爲python中的Elasticsearch-dsl
GET indexforproject/project/_search
{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"term": {
"project_language.languageName.raw": "nodejs"
}
}
}
}
}
這是我用來
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search,Q,query,F
client = Elasticsearch([{'host':'blrkec248770d','port':'9200'}])
temp="Internal"
s=Search(using=client, index="indexforproject").filter("term","project_language.languageName.raw"="Internal")
body={
'query':"PHP and node.js",
'filters':[{'name':"languages",'values':"[python,PHP,angular]"} ]
}
response=s.execute()
for hit in response:
print hit.title