0

ドキュメントには 2 つのインデックス付き属性があります - 名前 (文字列) とバージョン (番号)
同じスコア内でドキュメントは次の順序で表示されます

スコア(説明)、名前(説明)、バージョン(説明)

したがって、次を使用してクエリを実行します。

http://localhost:8983/solr/vault/select?
           q=BOM&fl=*:score& 
           sort=score+desc,Name+desc,Version+desc

そして、結果の中に次のように表示されます。

<doc>
   <str name="Name">BOM Total test2</str>
   ...
   <int name="Version">2</int>
   ...
   <float name="score">2.2388418</float>
</doc>
<doc>
   <str name="Name">BOM Total test - Copy</str>
   ...
   <int name="Version">2</int>
   ...
   <float name="score">2.2388418</float>
</doc>
<doc>
  <str name="Name">BOM Total test2</str>
  ...
  <int name="Version">1</int>
  ...
  <float name="score">2.2388418</float>
</doc>

スコアは同じですが、名前はソートされていません。

ここで何が間違っていますか?

EDIT : スキーマ定義

 ....
 <field name="Name" type="text_en" indexed="true" stored="true" required="true"/>
 <field name="Version" type="int" indexed="true" stored="true" required="true"/>
 ....
4

1 に答える 1

1

fieldTypeに適用されているすべてのトークン フィルター、アナライザーなどを見ると、text_en並べ替えには理想的ではありません。文字列値の並べ替えでは、並べ替えに特定の fieldType を使用することをお勧めします。過去に、文字列フィールドの並べ替えに次の fieldType を使用しました。

 <fieldType name="lowercase_sort" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.TrimFilterFactory" />
    </analyzer>
 </fieldType>

Solr Example スキーマには、並べ替え用の次の fieldType も含まれています。

 <fieldType name="alphaOnlySort" class="solr.TextField" 
     sortMissingLast="true" omitNorms="true">
  <analyzer>
    <!-- KeywordTokenizer does no actual tokenizing, so the entire
         input string is preserved as a single token
      -->
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <!-- The LowerCase TokenFilter does what you expect, which can be
         when you want your sorting to be case insensitive
      -->
    <filter class="solr.LowerCaseFilterFactory" />
    <!-- The TrimFilter removes any leading or trailing whitespace -->
    <filter class="solr.TrimFilterFactory" />
    <!-- The PatternReplaceFilter gives you the flexibility to use
         Java Regular expression to replace any sequence of characters
         matching a pattern with an arbitrary replacement string, 
         which may include back references to portions of the original
         string matched by the pattern.

         See the Java Regular Expression documentation for more
         information on pattern and replacement string syntax.

         http://java.sun.com/j2se/1.6.0/docs/api/java/util/regex/package-summary.html
      -->
    <filter class="solr.PatternReplaceFilterFactory"
            pattern="([^a-z])" replacement="" replace="all"
    />
  </analyzer>
</fieldType>

次に、次のように、並べ替え用の追加フィールドを定義します。

 <field name="Name_Sort" type="lowercase_sort" indexed="true" stored="false"/>

copyField を使用してこのフィールドに入力します

 <copyField src="Name" dest="Name_Sort"/>

次に、クエリでこの新しいName_Sortフィールドを並べ替えます。

于 2013-08-06T15:46:47.813 に答える