ElasticSearch - 由空格分割的术语聚合(ElasticSearch - terms aggregation split by whitespace)
我有一堆弹性搜索文档,其中包含有关招聘广告的信息。 我正在尝试聚合
attributes.Title
字段以从作业发布中提取“体验”实例的数量。 例如Junior,Senior,Lead等。相反,我得到的是与标题整体匹配的桶而不是标题字段的每个单词。 例如“初级Java开发人员”,“高级.NET分析师”等。我如何告诉弹性搜索根据标题中的每个单词拆分聚合,而不是匹配整个字段的值。
我后来想要扩展查询以提取“技能级别”和“角色”,但是如果存储桶包含字段中的所有单词,只要它们被拆分为单独的存储桶,它也应该没问题。
当前查询:
GET /jobs/_search { "query": { "simple_query_string" : { "query": "Java", "fields": ["attributes.Title"] } }, "size": 0, "aggs": { "group_by_state": { "terms": { "field": "attributes.Title.keyword" } } } }
不需要的输出:
{ ... "hits": { "total": 63, "max_score": 0, "hits": [] }, "aggregations": { "group_by_state": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 14, "buckets": [{ "key": "Junior Java Tester", "doc_count": 6 },{ "key": "Senior Java Lead", "doc_count": 6 },{ "key": "Intern Java Tester", "doc_count": 5 }, ... ] } } }
期望的输出:
{ ... "hits": { "total": 63, "max_score": 0, "hits": [] }, "aggregations": { "group_by_state": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 14, "buckets": [{ "key": "Junior", "doc_count": 12 },{ "key": "Senior", "doc_count": 8 },{ "key": "Tester", "doc_count": 5 },{ "key": "Intern", "doc_count": 5 },{ "key": "Analyst", "doc_count": 5 }, ... ] } } }
I have a bunch of elastic search documents that contain information about jobs ads. I'm trying to aggregate the
attributes.Title
field to extract the number of "experience" instances from the job posting. e.g. Junior, Senior, Lead, etc. Instead what I'm getting are buckets that match the title as a whole instead of the each word it the title field. e.g. "Junior Java Developer", "Senior .NET Analyst", etc.How can I tell elastic search to split the aggregation based on each word in the title as opposed the matching the value of the whole field.
I would later like to expand the query to also extract the "skill level" and "role", but it should also be fine if the buckets contain all the words in the field as long as they are split into separate buckets.
Current query:
GET /jobs/_search { "query": { "simple_query_string" : { "query": "Java", "fields": ["attributes.Title"] } }, "size": 0, "aggs": { "group_by_state": { "terms": { "field": "attributes.Title.keyword" } } } }
Unwanted Output:
{ ... "hits": { "total": 63, "max_score": 0, "hits": [] }, "aggregations": { "group_by_state": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 14, "buckets": [{ "key": "Junior Java Tester", "doc_count": 6 },{ "key": "Senior Java Lead", "doc_count": 6 },{ "key": "Intern Java Tester", "doc_count": 5 }, ... ] } } }
Desired Output:
{ ... "hits": { "total": 63, "max_score": 0, "hits": [] }, "aggregations": { "group_by_state": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 14, "buckets": [{ "key": "Junior", "doc_count": 12 },{ "key": "Senior", "doc_count": 8 },{ "key": "Tester", "doc_count": 5 },{ "key": "Intern", "doc_count": 5 },{ "key": "Analyst", "doc_count": 5 }, ... ] } } }
原文:https://stackoverflow.com/questions/46669017
最满意答案
发布模式
在发布模式下构建程序集时,编译器会执行所有可用的优化,以确保输出的可执行文件和库尽可能高效地执行。 此模式应用于要发布给最终用户的已完成和测试的软件。 释放模式的缺点是虽然生成的代码通常更快更小,但调试工具无法访问它。
调试模式
在开发软件时使用调试模式。 在调试模式下编译程序集时,会嵌入其他符号信息,并且不会优化代码。 这意味着编译器的输出通常更大,更慢且效率更低。 但是,可以将调试器附加到正在运行的程序,以允许在监视内部变量值的同时逐步执行代码。
Have a look at Visual Studio Debug and Release Modes
Release Mode
When an assembly is built in release mode, the compiler performs all available optimisations to ensure that the outputted executables and libraries execute as efficiently as possible. This mode should be used for completed and tested software that is to be released to end-users. The drawback of release mode is that whilst the generated code is usually faster and smaller, it is not accessible to debugging tools.
Debug Mode
Debug mode is used whilst developing software. When an assembly is compiled in debug mode, additional symbolic information is embedded and the code is not optimised. This means that the output of the compiler is generally larger, slower and less efficient. However, a debugger can be attached to the running program to allow the code to be stepped through whilst monitoring the values of internal variables.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
你提到你刚刚安装了XCode。 如果您希望开始使用C ++编程,那么使用XCode将比您使用Eclipse时更加令人满意并且学习曲线更快。 XCode是Mac上的“本机”IDE。 说了这些之后,我明白可能有理由使用Eclipse,例如,如果您希望在不久的将来开始在非Apple平台上编程,或者想要熟悉Eclipse作为进行Android编程的IDE。 但是,如果您要在Mac上使用一段时间并希望更快地获取C ++,我强烈建议坚持使用XCode。 现在,您显示的错误可能是因为该文件尚未保存,正如其中一位评论者所建 ...
-
使用Go构建包装C ++(Wrapping C++ with Go build)[2022-08-09]
几个月前我碰到了这个问题,花了很长时间才弄明白,但是我不记得我做了什么来修复它,但我认为它是这样的: 不要手动调用swig,这实际上使事情变得更加困难。 清理swig生成的文件。 在libsl-Generic中创建一个文件a.go,内容如下: package libsls-Generic 理论上你有一些其他的文件,比如app.go将使用libsls-Generic 。 编写app.go并适当地import libsls-Generic 。 使用go build app.go 这也应该构建依赖关系。 我最终 ... -
理解#includes c ++(Understanding #includes c++)[2022-02-03]
#include "Ah"字面意思是“插入文件的内容”啊“这里”。 因此,在编译主文件时,编译器会看到 void CreateRandomConvex() { //calc some stuff } class Scene { void Init() { CreateRandomConvex(); } }; int main() { } 作为旁注,有一个标题依赖于另一个已经包含的标题并不是一个很好的做法。 #include "A.h" literall ... -
构建的c ++问题(c++ problem with build)[2023-03-01]
似乎没有定义bit_vector 。 有人声称它应该包含在,但在Visual Studio 2008上似乎并非如此。请尝试 typedef vector bit_vector; 在第一次使用bit_vector 。 It seems bit_vector is not defined. There are claims that it should be included in , but that doesn't seem to be the case on ... -
理解C ++ [重复](Understanding C++ [duplicate])[2022-01-31]
您可以查看C ++编程语言 ,它类似于C ++程序员的Bible™,至少是新的收入者。 You can check The C++ Programming Language, which is like the Bible™ for C++ programmers, at least, new incomers. -
理解指针c ++(understanding pointers c++)[2023-12-26]
在第一行中,创建了一个指针,但它还没有指向任何东西。 在第二行中,您将创建一个实际的Animal对象。 In the first line, a pointer is created but it doesn't point to anything yet. In the second line you create an actual Animal object. -
理解Build c ++(understanding a Build c++)[2023-01-07]
看看Visual Studio调试和发布模式 发布模式 在发布模式下构建程序集时,编译器会执行所有可用的优化,以确保输出的可执行文件和库尽可能高效地执行。 此模式应用于要发布给最终用户的已完成和测试的软件。 释放模式的缺点是虽然生成的代码通常更快更小,但调试工具无法访问它。 调试模式 在开发软件时使用调试模式。 在调试模式下编译程序集时,会嵌入其他符号信息,并且不会优化代码。 这意味着编译器的输出通常更大,更慢且效率更低。 但是,可以将调试器附加到正在运行的程序,以允许在监视内部变量值的同时逐步执行代码。 ... -
C ++构建过程(C++ Build Process)[2022-05-14]
我目前正在开发一个开源C ++项目。 这简化了许多事情。 您应该为您的项目提供构建脚本,并为不同的用例支持它们(了解Makefile,有类似的概念,如“target”)。 我在C ++方面没有太多经验,因为我的日常工作主要涉及Java。 你在Java中习惯拥有(现在要求)的大部分东西都是因为缺乏C / C ++而发明的。 至少学习一些动态(共享)/静态库(.so和.a文件很简单)。 我现在正计划发布我的C ++项目,我想知道如何安排项目的包装。 “C ++项目的打包”是非正式的。 您可以为众所周知的IDE提 ...