1

我有几种由 ElasticSearch 索引的实体类型(通过 FOSElasticaBundle 使用 Elastica)。它们都有一个“重要性”属性,它是一个存储的整数。

我一直在使用功能分数查询,它可以很好地根据结果的重要性对结果进行排序。

在 elastica 中,它看起来像这样:

$nameQuery = new \Elastica\Query\QueryString();
$nameQuery->setFields(array('name'))
  ->setDefaultOperator('AND')
  ->setQuery($name);

//Create the script score that will modulate the score
$scriptScore = new \Elastica\Script("doc['importance'].value");

//Create the Function Score query that will bring it all together
$functionScoreQuery = new \Elastica\Query\FunctionScore();
$functionScoreQuery->setQuery($nameQuery);
$functionScoreQuery->addScriptScoreFunction($scriptScore);
$functionScoreQuery->setScoreMode('multiply');

$results = $this->find($functionScoreQuery);

这对我来说一直很好,直到我最近索引了一个新的实体类型。这种新的实体类型还有一个重要性属性,它也是一个存储的整数。现在,当我在新实体或旧实体(过去可以正常工作)上使用相同的函数分数查询时,我会遇到如下错误:

Query Failed      [  
         Failed to execute main query
      ]
   ]   ; nested:GroovyScriptExecutionException   [  
      ElasticsearchException      [  
         java.lang.NumberFormatException:Invalid shift value in prefixCoded bytes (is encoded value really an INT?)
      ]      ; nested:UncheckedExecutionException      [  
         java.lang.NumberFormatException:Invalid shift value in prefixCoded bytes (is encoded value really an INT?)
      ]      ; nested:NumberFormatException      [  
         Invalid shift value in prefixCoded bytes (is encoded value really an INT?)
      ]      ;
   ]   ;

一些搜索会产生很多想法,认为参数在整个 ElasticSearch 中都是全局的,因此我可能在其他一些名为“importance”的实体上有一个参数,它在任何地方都不是整数……但事实并非如此。我在数据库中唯一的“重要性”参数都是相同的整数。

我试过 -XPOST ' http://localhost:9200/index/_optimize?max_num_segments=1 ' 但这似乎也没有改变。我什至尝试根据另一个堆栈溢出讨论,在我的一个实体类型上将“整数”值更改为“长整数”并重新索引该实体,但这也没有做任何事情。

有人有想法么?这几天我一直在拔头发。

4

0 回答 0