如何在ElasticSearch 0.9中合并HighlightField Result和SearchHitField Result

时间:2014-12-12 08:00:25

标签: elasticsearch merge

我的代码是这样的:

{ 
  "took" : 7, 
  "timed_out" : false, 
  "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
  }, 
  "hits" : { 
    "total" : 2, 
    "max_score" : 0.29792547, 
    "hits" : [ { 
      "_index" : "pim", 
      "_type" : "contact", 
      "_id" : "8a92e6e5335f724b013361dacd1225bd", 
      "_score" : 0.29792547, 
      "fields" : { 
        "id" : "8a92e6e5335f724b013361dacd1225bd", 
        "phone" : [ { 
          "op" : "China Mobile", 
          "number" : "13681011893" 
        }, { 
          "op" : "China Mobile", 
          "number" : "13681011893" 
        }, { 
          "op" : "China Mobile", 
          "number" : "13681011893" 
        } ], 
      }, 
      "highlight" : { 
        "phone.number" : [ "1368101189<span class=\"hl\">136810</ 
span>3", "1368101189<span class=\"hl\">136810</span>3", 
"1368101189<span class=\"hl\">136810</span>3" ] 
      } 
    }] 
  } 
}

实际上,我想要这个结果:

{ 
  "took" : 7, 
  "timed_out" : false, 
  "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
  }, 
  "hits" : { 
    "total" : 2, 
    "max_score" : 0.29792547, 
    "hits" : [ { 
      "_index" : "pim", 
      "_type" : "contact", 
      "_id" : "8a92e6e5335f724b013361dacd1225bd", 
      "_score" : 0.29792547, 
      "fields" : { 
        "id" : "8a92e6e5335f724b013361dacd1225bd", 
        "phone" : [ { 
          "op" : "China Mobile", 
          "number" : "<span class=\"hl\">136810</span>11893" 
        }, { 
          "op" : "China Mobile", 
          "number" : "<span class=\"hl\">136810</span>11893" 
        }, { 
          "op" : "China Mobile", 
          "number" : "<span class=\"hl\">136810</span>11893" 
        } ], 
      } 
    }] 
  } 
}

也就是说,我们应该在弹性搜索搜索的原始源内容和突出显示内容之间得到结果,有人可以帮助我吗?

0 个答案:

没有答案