質問

Suppose, I have Solr document with several fields. Now, for some specific reason I have to modify one of the field's type. I know that, after modifying the "type" of that field, I won't be able to query with that field. Shall I be able to query by other fields?

My field definition was

<field name="searchtag" type="text_general" indexed="true" stored="true"/>

New definition is

<field name="searchtag" type="text_ngram" indexed="true" stored="true" multivalued="true"/>

Field type definitions

    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
        <!-- in this example, we will only use synonyms at query time
        <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
        -->
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

 <fieldType name="text_ngram" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="15"/>
    </analyzer>
    <analyzer type="query">
                <tokenizer class="solr.StandardTokenizerFactory"/>
                <filter class="solr.StandardFilterFactory"/>
                <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>

Thanks

役に立ちましたか?

解決

I found the answer.

I tried a small test case on my data on Solr-4.2.1. As I told, previously the type of the "searchtag" was text_general. I took a fresh Solr instance. There I defined searchtag as a text_general type field. There were also some other fields, I defined. Then I indexed some data into those fields as well as in searchtag. As it was a simple and straight forward way, so everything worked fine. I queried with searchtag and other fields and got the proper result.

Then I modified the schema.xml. I changed the type of the searchtag from text_general to text_ngram. After modifying the schema, I restarted the Solr instance. Now, I was not actually bothering about the data indexed for searchtag. Because I messed up with the schema for that field. So, I executed the same queries on the other fields. I'm happy that I got the same Solr documents as previous. Though I played with the schema, but other indexes for the other fields were intact. That's what I wanted.

Hope, this test case will help you in your area, if you stuck in this type of problem like me.

Note : I have mentioned the schema definition about "searchtag" and the field types in the question area.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top