首页 \ 问答 \ ElasticSearch - 由空格分割的术语聚合(ElasticSearch - terms aggregation split by whitespace)

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
更新时间:2024-01-21 12:01

最满意答案

看看Visual Studio调试和发布模式

发布模式

在发布模式下构建程序集时,编译器会执行所有可用的优化,以确保输出的可执行文件和库尽可能高效地执行。 此模式应用于要发布给最终用户的已完成和测试的软件。 释放模式的缺点是虽然生成的代码通常更快更小,但调试工具无法访问它。

调试模式

在开发软件时使用调试模式。 在调试模式下编译程序集时,会嵌入其他符号信息,并且不会优化代码。 这意味着编译器的输出通常更大,更慢且效率更低。 但是,可以将调试器附加到正在运行的程序,以允许在监视内部变量值的同时逐步执行代码。


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.

相关问答

更多
  • 你提到你刚刚安装了XCode。 如果您希望开始使用C ++编程,那么使用XCode将比您使用Eclipse时更加令人满意并且学习曲线更快。 XCode是Mac上的“本机”IDE。 说了这些之后,我明白可能有理由使用Eclipse,例如,如果您希望在不久的将来开始在非Apple平台上编程,或者想要熟悉Eclipse作为进行Android编程的IDE。 但是,如果您要在Mac上使用一段时间并希望更快地获取C ++,我强烈建议坚持使用XCode。 现在,您显示的错误可能是因为该文件尚未保存,正如其中一位评论者所建 ...
  • 几个月前我碰到了这个问题,花了很长时间才弄明白,但是我不记得我做了什么来修复它,但我认为它是这样的: 不要手动调用swig,这实际上使事情变得更加困难。 清理swig生成的文件。 在libsl-Generic中创建一个文件a.go,内容如下: package libsls-Generic 理论上你有一些其他的文件,比如app.go将使用libsls-Generic 。 编写app.go并适当地import libsls-Generic 。 使用go build app.go 这也应该构建依赖关系。 我最终 ...
  • #include "Ah"字面意思是“插入文件的内容”啊“这里”。 因此,在编译主文件时,编译器会看到 void CreateRandomConvex() { //calc some stuff } class Scene { void Init() { CreateRandomConvex(); } }; int main() { } 作为旁注,有一个标题依赖于另一个已经包含的标题并不是一个很好的做法。 #include "A.h" literall ...
  • 似乎没有定义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 ++编程语言 ,它类似于C ++程序员的Bible™,至少是新的收入者。 You can check The C++ Programming Language, which is like the Bible™ for C++ programmers, at least, new incomers.
  • 在第一行中,创建了一个指针,但它还没有指向任何东西。 在第二行中,您将创建一个实际的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.
  • 看看Visual Studio调试和发布模式 发布模式 在发布模式下构建程序集时,编译器会执行所有可用的优化,以确保输出的可执行文件和库尽可能高效地执行。 此模式应用于要发布给最终用户的已完成和测试的软件。 释放模式的缺点是虽然生成的代码通常更快更小,但调试工具无法访问它。 调试模式 在开发软件时使用调试模式。 在调试模式下编译程序集时,会嵌入其他符号信息,并且不会优化代码。 这意味着编译器的输出通常更大,更慢且效率更低。 但是,可以将调试器附加到正在运行的程序,以允许在监视内部变量值的同时逐步执行代码。 ...
  • 我目前正在开发一个开源C ++项目。 这简化了许多事情。 您应该为您的项目提供构建脚本,并为不同的用例支持它们(了解Makefile,有类似的概念,如“target”)。 我在C ++方面没有太多经验,因为我的日常工作主要涉及Java。 你在Java中习惯拥有(现在要求)的大部分东西都是因为缺乏C / C ++而发明的。 至少学习一些动态(共享)/静态库(.so和.a文件很简单)。 我现在正计划发布我的C ++项目,我想知道如何安排项目的包装。 “C ++项目的打包”是非正式的。 您可以为众所周知的IDE提 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。