2016-12-21 6 views
0

Solrには、長さを減らしたい多値フィールドがあります。次のように サンプル結果応答は次のとおりです。Solrの多値フィールドの長さを短くする方法

response": { 
    "numFound": 1, 
    "start": 0, 
    "docs": [ 
     { 
     "created_date": "2016-11-23T13:47:46.55Z", 
     "solr_index_date": "2016-12-01T08:21:59.78Z", 
     "modified_date": "2016-12-13T08:45:44.507Z",   
     "id": "FEAE38C2-ABFF-4F0C-8AFD-9B8F51036D8A",   
     "Field1": [ 
      "false", 
      "true", 
      "true", 
      ..... <= 1200 items 
     ] 
     } 
     ] 
    } 

我々はビッグデータ、TBのカップルを持っていると我々はSolrの内のすべての文書を変更すると、最初の100個の項目を含むようにフィールド1を修正するために最適化された方法を探しています。

手動でドキュメントをフェッチして調整し、それを再びsolrにプッシュするスクリプトを書かなくても、このようなことはできますか?誰も似たような経験をしていますか?ありがとう

答えて

1

私たちはこの問題に直面しました。しかし、この問題を解決するために2つのコレクションを使用しています。文書をあるコレクションから別のコレクションに移動するにはSoleEntityProcessorを使用します。

[SolrEntityProcessor] 

<dataConfig> 
    <document> 
    <entity name="sep" processor="SolrEntityProcessor" url="http://localhost:8983/solr/db" query="*:*"/> 
    </document> 
</dataConfig> 

我々は文書を編集したり、複数値フィールドを切り捨てることStatelessScriptUpdateProcessorFactoryを書くことができますupdateRequestProcessorChainを通じて文書のパスを移動しながら。
StatelessScriptUpdateProcessorFactoryでは、フィールドを取得して操作を適用し、そのフィールドをリセットすることができます。

[StatelessScriptUpdateProcessorFactory] 

function processAdd(cmd) { 
    doc = cmd.solrDoc; 
    multiDate = doc.getFieldValue("multiValueField"); 
    //Apply your operation to above field 
    //doc.setField("multiValueField",value); 

} 
function processDelete(cmd) { 
    // no-op 
} 

function processMergeIndexes(cmd) { 
    // no-op 
} 

function processCommit(cmd) { 
    // no-op 
} 

function processRollback(cmd) { 
    // no-op 
} 

function finish() { 
    // no-op 
} 

StatelessScriptUpdateProcessorFactoryの詳細については、あなたは彼らが、スクリプトを使用して複数値フィールドを編集するこの質問 On solr how can i copy selected values only from multi valued field to another multi valued field? を参照することができます。

関連する問題