1

ElasticSearch (FOSElasticaBundle 経由で 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);

最近新しいエンティティタイプにインデックスを付けるまで、これはうまく機能しています。この新しいエンティティ タイプには、格納された整数でもある重要度プロパティもあります。ここで、新しいエンティティまたは古いエンティティ (以前は正常に機能していた) のいずれかでこの同じ Function Score クエリを使用すると、次のようなエラーが発生します。

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?)
      ]      ;
   ]   ;

一部の検索では、params が ElasticSearch 全体でグローバルであるという多くの考えが得られるため、「importance」という名前の他のエンティティに、どこにも整数ではないパラメーターがある可能性がありますが、そうではありません。私がデータベースに持っている唯一の「重要な」パラメータは、すべて同一の整数です。

-XPOST ' http://localhost:9200/index/_optimize?max_num_segments=1 ' を試しましたが、これも何も変わらないようです。別のスタックオーバーフローの議論に基づいて、エンティティタイプの1つで「整数」値を「ロング」に変更し、エンティティのインデックスを再作成しようとしましたが、これも何もしませんでした。

誰にもアイデアはありますか?ここ数日、髪を抜いています。

4

0 に答える 0