elasticsearch-2.0 相关问题

Elastic的Elasticsearch产品达到了第2版

Elasticsearch:未捕获的引用错误:elasticsearch 未定义

我正在尝试使用 Elasticsearch 创建 NodeJS 应用程序 这是我的代码 我正在尝试使用 Elasticsearch 创建 NodeJS 应用程序 这是我的代码 <!DOCTYPE html> <script src="../bower_components/elasticsearch/elasticsearch.js"></script> <script> function esPinger() { var elasticsearch = require('elasticsearch'); var client = elasticsearch.Client({ host: 'localhost:9200', log: 'trace' }); client.ping({ // ping usually has a 3000ms timeout requestTimeout: Infinity, // undocumented params are appended to the query string hello: "elasticsearch!" }, function (error) { if (error) { console.trace('elasticsearch cluster is down!'); } else { console.log('All is well'); alert("YAY"); } }); } </script> <html> <head> <title>NodeJS Starter Application</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="stylesheets/style.css"> </head> <body> <center> <button onclick="esPinger()">Ping ES</button> </center> </body> </html> 我安装了elasticsearch客户端 npm install elasticsearch 还有 bower install elasticsearch 在我的项目文件夹中,我可以看到有一个bower_componenets文件夹,其中包含用于elasticsearch的所有.js文件,包括elasticsearch.js 现在,当我运行页面并单击按钮时,我得到了 Uncaught ReferenceError: elasticsearch is not defined 知道为什么吗?我缺少一些配置吗? 供参考,这是我的项目结构的样子 编辑 这是我在检查元素控制台中看到的内容 怎么拿不到图书馆! Node.JS 是一种“服务器端”技术,而不是“浏览器”技术。 因此,特定于节点的调用,例如: var elasticsearch = require('elasticsearch'); 不适用于浏览器。

回答 1 投票 0

使用 python 在 Elasticsearch 查询中进行用户身份验证

我正在使用 Python 来使用 elastisearch。我的代码看起来有点像这样:- 从 Elasticsearch 导入 Elasticsearch 如果 __name__ == '__main__': 索引=“索引位置” es=Elasticsearch(['

回答 7 投票 0

弹性搜索2.0搜索一样查询

这是我的模型。[ElasticsearchType(Name = "projectmodel")] public class ProjectModel { public string name { get; set; } public string description { get; set;}。嵌套] [...

回答 1 投票 0

ElasticProperty在弹性搜索2.0中的应用

我在 elastic search 1.0 中使用了以下 Elastic 属性 [ElasticProperty(Name = "description", Index = FieldIndexOption.Analyzed, Type = FieldType.String, Analyzer = "custom_lowercase_analyzer", ...

回答 1 投票 0

Elastic Search 2.0在主对象和嵌套对象中的搜索查询

[这是我的模型:公共班级学生{公共int ID {组; }公用字符串FirstName {get;组; }公用字符串LastName {get;组; } [嵌套]公共列表 ...] >>> 以REST API的形式提供答案,您可以将其转换为c#格式,因为我不熟悉它的语法,这对于那些不希望找到特定语言答案的人很有帮助。 使用示例数据进行了测试,下面是有效的解决方案 。 索引定义 { "student": { "properties": { "firstName": { "type": "string" }, "id": { "type": "integer" }, "lastName": { "type": "string" }, "subjects": { "type": "nested", "properties": { "id": { "type": "integer" }, "subjectName": { "type": "string" } } } } } } **索引样本文档既没有opster也没有subject和firstname ** { "firstName": "Isuru", "lastName": "foo", "id": 1, "subjects": [ { "id": 100, "subjectName": "math" }, { "id": 101, "subjectName": "opster" } ] } 索引另一个主题名称中没有opster的文档 { "firstName": "opster", "lastName": "tel aviv", "id": 1, "subjects": [ { "id": 100, "subjectName": "math" }, { "id": 101, "subjectName": "science" } ] } 搜索查询,请根据您的要求将must更改为should { "query": { "bool": { "should": [ --> note { "match": { "firstName": "opster" } }, { "nested": { "path": "subjects", "query": { "bool": { "must": [ -->note { "match": { "subjects.subjectName": "opster" } } ] } } } } ] } } } 搜索结果 "hits": [ { "_index": "nested", "_type": "student", "_id": "1", "_score": 0.39103588, "_source": { "firstName": "opster", "lastName": "tel aviv", "id": 1, "subjects": [ { "id": 100, "subjectName": "math" }, { "id": 101, "subjectName": "science" } ] } }, { "_index": "nested", "_type": "student", "_id": "2", "_score": 0.39103588, "_source": { "firstName": "Isuru", "lastName": "foo", "id": 1, "subjects": [ { "id": 100, "subjectName": "math" }, { "id": 101, "subjectName": "opster" } ] } } ] 您需要添加一个名字和姓氏匹配查询的should子句以及主题名称的嵌套查询。您不能在单个匹配或多重匹配查询中合并嵌套和非嵌套查询] var searchResponse = _elasticClient.Search<AssociateProfile>(s => s .Query(q => q .Bool(b=>b .Should( sh => sh.Match(m => m.Query(searchText).Field("student.firstName")), sh => sh.Match(m => m.Query(searchText).Field("student.lastName")), sh => sh.Nested(n => n .Path(p => p.VolunteerTasks) .Query(nq => nq.Match(m => m .Query(searchText).Field("subjects.subjectName"))) ) ) ) )); 借助于上述jaspreet chahal的第一个答案,我得以解决我的问题。 var searchResults = client.Search<Student>( body => body.Query( query => query.Bool( bq => bq.Should( q => q.Match(p => p.Field(f => f.FirstName).Boost(6).Query(searchText)), q => q.Match(p => p.Field(f => f.LastName).Boost(6).Query(searchText)), sh => sh.Nested(n => n.Path(p => p.Subjects).Query(nq => nq.Match( m => m.Query(searchText).Field("subjects.subjectName") ) ) ) ) ) ).Size(MAX_RESULT) ); 但是我需要为searchText输入准确的词以获取结果。例如,SubjectName-“科学与技术” 如果我使用技术进行搜索,它将返回记录。但是,如果使用techno搜索,它不会返回记录。如何解决此问题?

回答 3 投票 1

如何让Elasticsearch从search_as_you_type字段中突出显示部分单词?

我在设置search_as_you_type字段时遇到麻烦,请按照此处的指南进行突出显示:https://www.elastic.co/guide/zh-cn/elasticsearch/reference/7.x/search-as-you-type.html我会留下一个...

回答 1 投票 0

如何使用nodejs在elasticsearch中获取索引的总数或总索引项

我正在尝试使用nodejs来获取Elasticsearch索引的总数,但是我不知道如何获取该计数。有人可以帮我吗

回答 1 投票 -1

如何将弹性搜索中的短语与可扩展前缀和后缀匹配?

我们有一个用例,我们希望在弹性搜索中匹配短语,但除了短语查询,我们还想搜索部分短语。示例:搜索短语:“欢迎你”或“欢迎你”......

回答 1 投票 0

弹性搜索组由过滤器不起作用

我在索引时加入了几个表,同时尝试通过它来获取组不起作用。最初我执行了这个{“size”:10000,“query”:{“constant_score”:{...

回答 1 投票 0

ElasticSearch无法找到分析仪?

我在elasticsearch.yml中配置了我的全局自定义分析器,这是我的配置:index:analysis:analyzer:titleAnalyzer:type:custom tokenizer:...

回答 1 投票 2

© www.soinside.com 2019 - 2024. All rights reserved.