小编Sen*_*ini的帖子

ElasticSearch用单词内的连字符搜索

我想寻求帮助。我想在标题和内容中搜索一个单词。这是结构

'body' => array(
  'mappings' => array(
    'myindex' => array(
      '_source' => array(
        'enabled' => true
      ),
      'properties' => array(
        'Title' => array(
          'type'  => 'string',
          'fields'=> array(
            'raw' => array(
               'type'  => 'string',
               'index' => 'not_analyzed'
              )
            )
          ),
          'Content' => array(
            'type'  => 'string'
          ),
          'Image' => array(
             type'      => 'string',
             'analyzer'  => 'standard'
         )
       )
     )
   )
 )
Run Code Online (Sandbox Code Playgroud)

查询字符串看起来像这样,在这里我想在“ 15-game”之类的文本中搜索“ 15-g”:

"query" : {
  "query_string": {
    "query": "*15-g*",
    "fields": [ "Title", "Content" ]
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我重复这个问题,请接受我的道歉,但我无法查明正在发生什么以及为什么它不返回任何结果。

我已经看过: …

search hyphen elasticsearch

5
推荐指数
1
解决办法
7723
查看次数

按列在aggs中进行弹性搜索排序

我正在尝试在 aggs 中对弹性搜索进行排序,相当于在 mysql“ORDER BY Title ASC/DESC”中。这是索引结构:

'body' => array(
  'mappings' => array(
    'test_type' => array(
      '_source' => array(
        'enabled' => true
    ),
    'properties' => array(
      'ProductId' => array(
        'type'      => 'integer',
         'index'     => 'not_analyzed'
      ),
      'Title' => array(
        'type'      => 'string',
        'index'     => 'not_analyzed'
      ),
      'Price' => array(
        'type'      => 'double',
         'index'     => 'not_analyzed'
                        )
    )
  )
)
Run Code Online (Sandbox Code Playgroud)

我可以按价格订购如下:

{
      "aggs": {
        "group_by_product": {
          "terms": {
            "field": "ProductId",
              "order": {
                "product_price" : "asc"
            }
          },
          "aggs": {
            "product_price": { …
Run Code Online (Sandbox Code Playgroud)

sorting group-by elasticsearch

2
推荐指数
1
解决办法
4689
查看次数

标签 统计

elasticsearch ×2

group-by ×1

hyphen ×1

search ×1

sorting ×1