2016-09-26 1 views
2

Solrを使用して大文字と小文字を区別しない並べ替えを実現しようとしています。this issueに直面しています。docvalues = trueの場合、小文字のフィルタファクトリは機能しません。

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
 
<schema name="autoSolrSchema" version="1.5"> 
 
\t <types> 
 
\t \t ............... 
 
\t \t <fieldType class="org.apache.solr.schema.TextField" name="TextField"> 
 
\t \t \t <analyzer> 
 
\t \t \t \t <tokenizer class="solr.KeywordTokenizerFactory"/> 
 
\t \t \t \t <filter class="solr.LowerCaseFilterFactory"/> 
 
\t \t \t </analyzer> 
 
\t \t </fieldType> 
 
\t \t ............. 
 
\t </types> 
 
\t <fields> 
 
\t ................. 
 
\t \t <field indexed="true" multiValued="false" name="name" stored="true" type="TextField" docValues="true" /> 
 
\t ................ \t 
 
\t </fields> 
 
\t <uniqueKey>id</uniqueKey> 
 
\t </schema>

は私がthe solutionに続いて、私のSolr schema.xmlファイルを次のように変更し(のみreleventフィールドとフィールドタイプが示されている)製の

....But When I get search result its not sorted case insensitive. It gives all camel case result first and then all lower case 

If I m having short names 

Banu 

Ajay 

anil 

sudhir 

Nilesh 

It sorts like Ajay, Banu, Nilesh, anil, sudhir 
................... 

を[コピーしました]

しかし、それはソートの問題を解決しませんでした。だから私はフィールド定義からdocValues="true"を削除して再試行しました。このソートはうまくいきましたが、クエリにはuseFieldCache=trueを指定しなければなりませんでした。

なぜsolr.LowerCaseFilterFactorydocValues="true"で動作しないのですか?

docValues="true"を削除し、useFieldCache=trueを指定しないで、大文字と小文字を区別しない並べ替えを行う方法はありますか?

更新:

私はericLavaultのアドバイスに従い、更新要求プロセッサを実装しました。しかし、今私は以下の問題に直面しています:

1)私たちはdse searchを使用しています。助言、私はlowecaseするNMを変換して挿入されたよう

Solr schema : 
 

 
<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
 
<schema name="autoSolrSchema" version="1.5"> 
 
\t <types> 
 
\t \t <fieldType class="org.apache.solr.schema.UUIDField" name="UUIDField"/> 
 
\t \t <fieldType class="org.apache.solr.schema.StrField" name="StrField"/> 
 
\t </types> 
 
\t <fields> 
 
\t \t <field indexed="true" multiValued="false" name="nm" stored="true" type="StrField" docValues="true"/> 
 
\t \t <field indexed="true" multiValued="false" name="id" stored="true" type="UUIDField"/> 
 
\t \t <field indexed="true" multiValued="false" name="nm_s" stored="true" type="StrField" docValues="true"/> 
 
\t </fields> 
 
\t <uniqueKey>id</uniqueKey> 
 
</schema>

CREATE TABLE IF NOT EXISTS test_data(
    id  UUID, 
    nm  TEXT, 
    PRIMARY KEY (id) 

Solrのスキーマ:だからthis article.

に私たちの現在のテーブルのスキーマを指定する方法が続きます更新リクエストプロセッサを使用してnm_sその後、スキーマを再ロードして再インデックス化しました。私は値nm_sが正しく更新されていることを確認するにはどうすればよい

...enable docvalues true n reindex or place useFieldCache=true... 

2):しかし、このselect nm from test_data where solr_query='{"q": "(-nm:(sssss))" ,"paging":"driver","sort":"nm_s asc"}';

を使用して照会しながら、私は次のエラーを取得していますか? nm_sの値を見る方法はありますか?

3) docValuesが有効になっていても、上記のエラーが表示されるのはなぜですか?

+0

フィールド定義を変更した後(docValuesの追加/削除時)にコンテンツのインデックスを再作成しましたか? – EricLavault

+0

@ nttting yes ... – Sharun

+0

okこれは頼んで申し訳ありませんが、あなたは決して知りません! :)私はこれに手掛かりを持っていると思う、ちょうど – EricLavault

答えて

2

この問題は、おそらくDocValuesが元々解析されていないタイプをサポートするように設計されていることに起因すると考えられます。それはTextFieldをサポートしていません:

https://cwiki.apache.org/confluence/display/solr/DocValuesより引用)

DocValues are only available for specific field types. The types chosen determine the underlying Lucene docValue type that will be used. The available Solr field types are:

  • StrField and UUIDField :
    • If the field is single-valued (i.e., multi-valued is false), Lucene will use the SORTED type.
    • If the field is multi-valued, Lucene will use the SORTED_SET type.
  • Any Trie* numeric fields, date fields and EnumField.
    • If the field is single-valued (i.e., multi-valued is false), Lucene will use the NUMERIC type.
    • If the field is multi-valued, Lucene will use the SORTED_SET type.

をテキストフィールド(SOLR-8362)用docValuesのサポートを追加するためのSolrのJira上の問題が、まだオープンして割り当てられていないがあります。


docValues="true"を削除せずに作業を並べ替え大文字と小文字を区別をするために、あなたは文字列フィールドタイプ(solr.StrField)を使用する必要がありますが、あなたは文字列型を持つ任意の<analyser>を定義することはできませんので、あなたは小文字にUpdate Request Processorが必要になります入力ストリーム(または、Solrにデータを送信する前にフィールドコンテンツを前処理するのと同等のもの)。

あなたのフィールドが検索のためにトークン化したいとはDocValuesを使用してソートされた場合は、あなたが上でソートするあなたの実際(DocValuesなし)テキストフィールドと文字列フィールドに基づいてcopyFieldを使用することができます(小文字のために処理DocValuesが有効な場合)。

+0

に答える前にチェックしなければならない "...ソートされるフィールドでは、文字列型として定義されています.." - あなたは 'StrField'を意味しますか? – Sharun

+0

@Sharun yes、または* solr.StrField *を使用するフィールド(デフォルトでは、schema.xmlに ''があります) – EricLavault

+0

StrFieldのはどうですか? – Sharun

関連する問題