Tag: elasticsearch

写一个查询来提高结果,如果它属于一个特定types的字段

我正在使用Elasticsearch与Node.js现在我遇到的问题是,我想编写一个查询,如果我想提高我的结果,如果它属于特定types的字段,例如,如果我有索引:商人和types:餐厅,时尚两种types都有一个字段shop_name ,现在我想我的search结果得到提升到2倍,如果shop_name是餐厅types而不是时尚。 我已经写了我的查询如下 index: 'merchants', type: ['fashion', 'restaurant'], body: { "query":{ bool: { "disable_coord": true, should: [ { "constant_score": { boost: 1.00, // HERE BOOST IS 1 as field is in type FASHION "query": { "wildcard" : { "fashion.shop_name" : last_wildcard_string } } } }, { "constant_score": { boost: 2.00, // HERE BOOST IS 2 […]

在与database-nodeJS的连接上同步elasticsearch

目标 :将elasticsearch与postgres数据库同步 为什么 :有时候新networking或群集/服务器会中断,以便将来的更新应该被logging 本文https://qafoo.com/blog/086_how_to_synchronize_a_database_with_elastic_search.htmlbuild议我应该创build一个单独的表updates ,它将同步elasticsearch的id ,允许从上一条logging(在elasticsearch中)select新的数据(从数据库)。 所以我想如果我可以loggingelasticsearch的失败和成功的连接:如果client成功返回(返回一个承诺),我可以启动一个函数来同步logging与我的数据库。 这是我的elasticConnect.js import elasticsearch from 'elasticsearch' import syncProcess from './sync' const client = new elasticsearch.Client({ host: 'localhost:9200', log: 'trace' }); client.ping({ requestTimeout: Infinity, hello: "elasticsearch!" }) .then(() => syncProcess) // successful connection .catch(err => console.error(err)) export default client 这样,我甚至不用担心运行cron作业(如果问题1是正确的),因为我知道集群正在运行。 问题 syncProcess会在export default client之前运行吗? 我不想在同步时进入任何请求… syncProcess只能运行一次(因为它被caching/不导出),无论我import多less次elasticConnect.js 。 正确? 使用updates表的方法是否有任何优势,而不是从父/源表中select数据? […]

如何将Firebase手电筒集成到我的应用程序中

我正在尝试将Firebase Flashlight与ElasticSearch集成到Node.js应用程序中,以便对我的Firebase集合进行search操作。 我想在api.js中定义我的searchpath(例如: myhost: myport/ search/mycollection/:key )。 问题是myport与ElasticSearch运行的是不同的(9200)。 我想在路线上: myhost: myport/whatever运行我的应用程序,并在路线myhost: myport/ search/mycollection/:key运行search,现在可以在myhost:9200 。 我如何将它们整合到Express中? 当我configurationElasticSearch时,我使用: var config = { host: 'localhost', port: 9200, log: 'trace' }; var esc = new ElasticSearch.Client(config);

将Nodejs应用程序容器安全地连接到弹性search容器(Docker)

Elasitcsearch没有内置的安全性,所以我需要自己处理它,我认为这样做的最好方式是从中删除公共访问,只允许通过API访问节点的Web应用程序。 但是我仍然可以在端口0.0.0.0:9200上访问弹性search,我基本上只想让节点应用程序能够与elasticsearch进行通信。 version: "2" services: elasticsearch: image: elasticsearch ports: – "9200:9200" node-bot: build: . volumes: – "./dist:/dist" links: – elasticsearch ports: – "3030:3005" depends_on: – "elasticsearch" 希望这是有道理的,在此先感谢。

使用筛选器和聚合的弹性search查询不返回聚合

我正在使用node.js sdk来运行一个elasticsearch查询,该查询会search所有字段的一些文本,然后将结果过滤到一个子集,然后根据自定义索引进行聚合。 我查看了es文档以及涉及filter和聚合的几个堆栈溢出问题,以确保我的查询语法正确,并且在查询运行时没有看到语法错误。 我的查询在我的数据集中击中了2000多个文档,但响应对象不包含聚合。 var search_text = "Chase Bank"; var doctype_selections = ["mortgage"]; es.search({ index: index_list, type: 'page', body: { query: { filtered: { query: { match: { _all: { "query": search_text, "operator": "and" } }, filter: { terms: { document_type: doctype_selections } } } } }, aggs: { "top_tag_hits":{ terms: { field: "agg_index", size: […]

Elasticsearch使用多个filtersearch查询

大家好我是新的弹性search,但我已经通过基本的ElasticSearch 5.1文档。 问题在一行中: search成功,但filter工作不正常。 映射数据types { "properties": { "title": {"type": "string"}, "description": {"type": "string"}, "slug": {"type": "string"}, "course_type": {"type": "string", "index" : "not_analyzed"}, "price": {"type": "string"}, "categories": {"type": "keyword", "index" : "not_analyzed"}, "tags": {"type" : "keyword"}, // "tags": {"type" : "keyword", "index" : "not_analyzed"}, "status": {"type" : "string","index" : "not_analyzed"}, } } 正如@Darth_Vader所指出的,我也尝试过映射。 以下是我的映射 索引中的文档(Req-1) […]

Elasticsearch使用lowercase_expanded_terms的正则expression式filter语法

问题: 我想要执行一个匹配文本的查询,然后在某个字段上执行一个正则expression式filter。 对于我的生活,我不能找出一个正则expression式filter的正确语法。 (我正在使用node.js客户端来执行查询) 说明: 我的文件中index:'not_analyzed'被设置为index:'not_analyzed' 。 我已经validation了查询工作没有过滤条款。 我已经validation了在'T2-R3'模式下的陆地领域有项目。 我从阅读文档了解到,有必要在查询中包含lowercase_expanded_terms: false参数,因为正则expression式扩展的默认行为只是小写。 我的查询有什么问题: es.search({ index: index_list, type: 'page', body: { query: { bool: { must: [ {match: { _all: { "query": search_text, "operator": "and" }}}, ], filter: [ {"regexp": {land: 'T*', lowercase_expanded_terms: false}} ] } }, aggs: { "top_tag_hits":{ terms: { field: "agg_index", size: agg_size }, […]

在Elasticsearch中使用nodejs创build索引时出错

我正在使用npm elasticsearch,因为得到这样的错误 client.index不是一个函数 这是我的代码 encryptObj = enpyt.encrypt(function(encrypted){ client.index({ index: 'collectionnew3 id: '101', type: 'collectiontype3', body: { "username": "postgres", "pswrd": encrypted, } },function(err,resp,status) { console.log(resp); }) }) 任何想法,为什么我得到这个?

有没有一种方法可以使用elasticsearch返回每个匹配字段只有一个命中?

注:更新为包含NodeJS客户端详细信息。 请参阅下面的编辑。 我试图避免不得不反复查询ElasticSearch来获取我需要的信息。 假设我有一个由城市中的事件组成的数据集。 数据集中的文档可能如下所示: { city: 'Berlin', event: 'Dance party', date: '2017-04-15' }, { city: 'Seattle', event: 'Wine tasting', date: '2017-04-18' }, { city: 'Berlin', event: 'Dance party, date: '2017-04-21' }, { city: 'Hong Kong', event: 'Theater', date: '2017-04-25' }… 现在说所有跟踪城市的名单是已知的,我需要得到每个城市最近的事件。 因此,我需要能够在查询中input一系列城市名称,例如['Berlin', 'Hong Kong', 'Seattle']并只返回底部的三个事件。 我目前的查询只能通过以1的大小重复运行,并在城市名称上进行精确匹配来实现,如下所示: { size: 1, body: { sort: [ {'date': […]

如何使用nodejs elasticsearch客户端指定路由?

似乎没有办法在索引操作中指定路由值。 我试图使用这里提到的“无证参数”: https : //www.npmjs.org/package/elasticsearch 例如client.search({index:'abc',type:'efg',路由:'123'…} 我会得到'路由'错误,因为在映射中需要路由。 这是一个错误,缺lessfunction,或者我没有设置正确的参数? 请帮忙