我的Elasticsearch查询有问题. 我希望能够对结果进行分类,但是Elasticsearch忽略了排序标签.在这里我的查询: { "sort": [{ "title": {"order": "desc"} }], "query":{ "term": { "title": "pagos" } } } 但是,当我删除查询零件并仅发送排序标签时,它可以工作. 谁能指出正确的方式? 我还尝试了以下查询,这是我拥有的完整查询: { "sort": [{ "title": {"order": "asc"} }], "query":{ "bool":{ "should":[ { "match":{ "title":{ "query":"Pagos", "b
以下是关于 elasticsearch-py 的编程技术问答
我正在使用Python生成大量带有随机内容的Elasticsearch文档,并与/a>. 简化的工作示例(只有一个字段的文档): from elasticsearch import Elasticsearch from random import getrandbits es_client = Elasticsearch('https://elastic.host:9200') for i in range(1,10000000): document = {'my_field': getrandbits(64)} es_client.index(index='my_index', document=document) 由于这提出了每个文档的一个请求,因此我尝试通过使用_bulk api发送1000个文档的块来加快速度.但是,到目前为止,我的尝试没有成功. 我对文档的理解是,您可以将一个值得称赞到bulk(),所以我尝试了: from ela
根据 docs 应该足够: "settings": { "index.mapping.ignore_malformed": true } 但是我该如何在Python包装纸上实现这一目标?我当前的代码看起来像这样: from elasticsearch_dsl import Index index = Index('my_index', my_conn) index.settings( number_of_shards=ES_NUMBER_OF_SHARDS, number_of_replicas=ES_NUMBER_OF_REPLICAS ) index.create() 解决方案 令人惊讶的是, index.settings( index={'mapping':{'ignore_malformed':True}} ) 工作得很好.我会在这里留下Q,因为可能很有用.
我使用Python 3在Pyspark中使用了elasticsearch-py客户端,并且我将使用与RDD结合使用的ES遇到了Analyze()函数遇到问题.特别是,我的RDD中的每个记录都是一串文本,我正在尝试进行分析以获取令牌信息,但是当尝试在Spark中使用地图功能中使用它时,我会遇到错误. 例如,这可以很好地工作: from elasticsearch import Elasticsearch es = Elasticsearch() t = 'the quick brown fox' es.indices.analyze(text=t)['tokens'][0] {'end_offset': 3, 'position': 1, 'start_offset': 0, 'token': 'the', 'type': ''} 但是,当我尝试一下时: trdd = sc.parallelize(['the quick brown fox']) t
我有一个带有2个节点的群集. 我正在尝试了解连接节点的最佳实践,并在一个节点上停机时检查故障转移. 来自文档: es = Elasticsearch( ['esnode1', 'esnode2'], # sniff before doing anything sniff_on_start=True, # refresh nodes after a node fails to respond sniff_on_connection_fail=True, # and also every 60 seconds sniffer_timeout=60 ) 所以我试图像这样连接到我的节点: client = Elasticsearch([ip1, ip2],sniff_on_start=True, sniffer_timeout=10,sniff_on_connection_fail=True) ip1/ip2
因此,我们在Django项目中使用Elasticsearch,我们正在使用Elasticsearch-DSL Python库. 我们在生产中有以下错误: ConflictError(409, '{"took":7,"timed_out":false,"total":1,"deleted":0,"batches":1,"version_conflicts":1,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[{"index":"events","type":"_doc","id":"KJ7SpWsBZnen1jNBRWWM","cause":{"type":"version_conflict_engine_exception","reason":"[KJ7SpWsBZne
有人有一个有关如何使用更新的示例吗?它已记录在这里并且不包括工作示例.我尝试了以下内容: coll = Elasticsearch() coll.update(index='stories-test',doc_type='news',id=hit.meta.id, body={"stanford": 1, "parsed_sents": parsed }) 我得到 elasticsearch.exceptions.RequestError: TransportError(400, u'ActionRequestValidationException[Validation Failed: 1: script or doc is missing;]') 我想使用部分文档进行更新,但是更新方法不使用任何名为" doc"或"文档"的参数. 解决方案 您快到了,您只需要将您的身体包围在" DOC"字段中.使用Elasticsearch-
我在Elasticsearch中有一些数据.如图像所示 我使用以下链接示例进行滚动 page = es.search( index = INDEX_NAME, scroll = '1m', size = 1000, body={"query": {"match_all": {}}}) sid = page['_scroll_id'] scroll_size = page['hits']['total'] # Start scrolling print( "Scrolling...") while (scroll_size > 0): print("Page: ",count) page = es.scroll(scroll_id = sid, scroll = '10m') # Update the scroll ID sid = p
我有以下格式包含嵌套表的文档: { "dataId": "dataIdentifier", "versionId": "versionIdentifier", "items": [ { "obj1": "value1", "obj2": "value2", "obj3": "value3", }, { "obj1": "value4", "obj2": "value5", "obj3": "value6" }, { "obj1": "value7", "obj2": "value8", "obj3": "value9" } ] } 带有嵌套类型的"项目".我想删除给定的"项目"中的一个元素,而不是内部的一个对象具有一定的值.例如: if (obj1 == "value4" & dataId == "dataIdentifier" & versionId == versionIdentifier) : DELETE TABLE ENTRY
我正在使用elasticsearch-py在弹性中向索引添加一些命令, 我在索引和字典中添加了字典,其中包含列表,在我的代码中添加了此字典,但它给了我这样的错误: RequestError: TransportError(400, u'mapper_parsing_exception', u'failed to parse [long_spec]') 搜索后,我知道我应该在弹性中添加一些地图,然后在映射中添加"long_spec":{ "type": "text" }以及其他测试"long_spec"{ "type": "string" },但它不起作用. 我在我的python中使用它 self.es.index(index="new_index", doc_type='user',body=dict) 我的命令就是这样: {'long_spec': [{'header': u'Design', 'specification': [{u'Device type:': [u'S
如何编写Elasticsearch-Py查询以查询与下面相同的数据? --data-binary '{"query": {"filtered": {"query": {"bool": {"should":[ {"query_string": {"query":"request.action.raw:\"aaa\" AND (loglevel:INFO)"}}, {"query_string": {"query":"request.action.raw:\"bbb\" AND (loglevel:INFO)"}}, {"query_string": {"query":"request.action.raw:\"ccc\" AND (loglevel:INFO)"}}, } }, "filter": {"bool": {"must":[ {"range": {"@timestamp": {"from":111,"to":222}}}, {"fquery": {"query": {"qu
我正在尝试使用Python客户端进行弹性搜索,以使用SQL访问进行弹性搜索查询索引.我想使用SQL语法查询索引.如何向Elasticsearch指定必须读取SQLSYNTAX? def searchText(text): t1 = time.time() es=Elasticsearch([{'host':'localhost','port':9200}]) res = es.search(index='global_res_todos_acco', size=10000, request_timeout=60, body={'query':{ "select * from global_res_todos_acco limit 100 where EntityList = " + text
我正在尝试将此Kibana查询转换为Python: PUT /.kibana/_doc/index-pattern:tempindex { "type": "index-pattern", "index-pattern": { "title": "tempindex", "timeFieldName": "sendTime" } } 这就是我到目前为止所拥有的: HEADERS = { 'Content-Type': 'application/json' } uri = "http://localhost:5601/_doc/index-pattern:tempindex" query = json.dumps({ "type": "index-pattern", "index-pattern": { "title": "tempindex", "timeFieldName": "sendTime" }
我正在尝试实现索引使用 elasticsearch-dsl .基本上有两个步骤: 1.创建别名: PUT /tweets_1/_alias/tweets_search PUT /tweets_1/_alias/tweets_index 2.必要时更改别名: POST /_aliases { "actions": [ { "add": { "index": "tweets_2", "alias": "tweets_search" }}, { "remove": { "index": "tweets_1", "alias": "tweets_index" }}, { "add": { "index": "tweets_2", "alias": "tweets_index" }} ] } 我只能使用 elasticsearch-py (((不是DSL): from elasticsearch.clien
我正在使用 2 种类似的 ES 方法来加载和删除文档: result = es.search(index='users_favourite_documents', doc_type='favourite_document', body={"query": {"match": {'user': user}}}) 还有: result = es.delete_by_query(index='users_favourite_documents', doc_type='favourite_document', body={"query": {"match": {'user': user}}}) 第一个工作正常并返回预期的记录. 第二个抛出异常: “传输错误(404,'{ \"找到\":假,