0

这让我发疯了好几个小时。我不知道该怎么做。在我的本地机器上,重建索引工作正常。在我们的服务器上也是如此。在以与旧服务器相同的方式设置的新服务器上,它会失败。

这是我得到的输出:

Indexing 0 billboard items.
Indexing 0 companys.
Indexing 1 personal profiles.
Failed to add documents to Solr: [Reason: Error 400 [doc=null] missing required field: site_id]
Indexing 0 degrees.
Indexing 0 work experiences.

该错误会出现在所有模型上,我清理了数据库并添加了一个 PersonalProfile,这就是为什么您在这里只看到一个模型的原因。

我的模型都没有site_id字段。我们正在使用 django-blog-zinnia,它利用了 Django 的站点框架,但我们根本没有将 zinnia 添加到搜索中。我们的整个代码库根本不包含这个词site_id,除了百日草的南迁。

在我的 requirements.txt 我正在使用:

-e git+git://github.com/toastdriven/django-haystack.git@a169ff696ffb739a2ceb0f18c536d5b54c59a235#egg=haystack
pysolr==2.1.0

我的 search_indexes.py 看起来像这样:

class WorkExperienceIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    user = indexes.CharField()
    job_title = indexes.CharField()
    industry = indexes.CharField(null=True)
    company_name = indexes.CharField(null=True)
    location = indexes.CharField(null=True)
    start_date = indexes.DateField(null=True)
    end_date = indexes.DateField(null=True)
    job_summary = indexes.CharField(null=True)
    technical_skills = indexes.CharField(null=True)
    courses_taken = indexes.CharField(null=True)

    def get_model(self):
        return WorkExperience

    def prepare_user(self, obj):
        return obj.user.email

在 myproject/templates/search_configuration/solr.xml 我有这个:

<?xml version="1.0" ?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<schema name="default" version="1.4">
    <types>
        <fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
        <fieldtype name="binary" class="solr.BinaryField"/>

    <!-- Numeric field types that manipulate the value into
        a string value that isn't human-readable in its internal form,
        but with a lexicographic ordering the same as the numeric ordering,
        so that range queries work correctly. -->
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>

    <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>

    <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
    <!-- A Trie based date field for faster date range queries and date faceting. -->
    <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

    <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
    <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
    <fieldtype name="geohash" class="solr.GeoHashField"/>

    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <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.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <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_en" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords_en.txt"
                enablePositionIncrements="true"
                />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
            <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
            <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
                <filter class="solr.EnglishMinimalStemFilterFactory"/>
            -->
            <filter class="solr.PorterStemFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.StopFilterFactory"
                ignoreCase="true"
                words="stopwords_en.txt"
                enablePositionIncrements="true"
                />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
            <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
            <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
                <filter class="solr.EnglishMinimalStemFilterFactory"/>
            -->
            <filter class="solr.PorterStemFilterFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
        <analyzer>
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="ngram" class="solr.TextField" >
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="15" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="edge_ngram" class="solr.TextField" positionIncrementGap="1">
        <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
            <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
        </analyzer>
    </fieldType>
</types>

    <fields>
        <!-- general -->
        <field name="{{ ID }}" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
        <field name="{{ DJANGO_CT }}" type="string" indexed="true" stored="true" multiValued="false"/>
        <field name="{{ DJANGO_ID }}" type="string" indexed="true" stored="true" multiValued="false"/>

    <dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
    <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
    <dynamicField name="*_l"  type="long"   indexed="true"  stored="true"/>
    <dynamicField name="*_t"  type="text_en"    indexed="true"  stored="true"/>
    <dynamicField name="*_b"  type="boolean" indexed="true"  stored="true"/>
    <dynamicField name="*_f"  type="float"  indexed="true"  stored="true"/>
    <dynamicField name="*_d"  type="double" indexed="true"  stored="true"/>
    <dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
    <dynamicField name="*_p" type="location" indexed="true" stored="true"/>
    <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false"/>

{% for field in fields %}
    <field name="{{ field.field_name }}" type="{{ field.type }}" indexed="{{ field.indexed }}" stored="{{ field.stored }}" multiValued="{{ field.multi_valued }}" />
{% endfor %}
    </fields>

    <!-- field to use to determine and enforce document uniqueness. -->
    <uniqueKey>{{ ID }}</uniqueKey>

    <!-- field for the QueryParser to use when an explicit fieldname is absent -->
    <defaultSearchField>{{ content_field_name }}</defaultSearchField>

    <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
    <solrQueryParser defaultOperator="{{ default_operator }}"/>
</schema>

当我尝试重建索引时,我正在这样做:

supervisorctl stop solr
workon kairos && $HOME/webapps/kairos_django/myproject/manage.py build_solr_schema > $HOME/opt/apache-solr-3.5.0/example/solr/conf/schema.xml
supervisorctl start solr
workon kairos && $HOME/webapps/kairos_django/myproject/manage.py rebuild_index --noinput

这是我从中得到的生成的 schema.xml:

<?xml version="1.0" ?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<schema name="default" version="1.4">
    <types>
        <fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
        <fieldtype name="binary" class="solr.BinaryField"/>

    <!-- Numeric field types that manipulate the value into
       a string value that isn't human-readable in its internal form,
       but with a lexicographic ordering the same as the numeric ordering,
       so that range queries work correctly. -->
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>
    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" sortMissingLast="true" positionIncrementGap="0"/>

    <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>

    <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
    <!-- A Trie based date field for faster date range queries and date faceting. -->
    <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

    <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
    <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
    <fieldtype name="geohash" class="solr.GeoHashField"/>

    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <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.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <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_en" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <filter class="solr.StopFilterFactory"
               ignoreCase="true"
               words="stopwords_en.txt"
               enablePositionIncrements="true"
               />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
            <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
            <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
               <filter class="solr.EnglishMinimalStemFilterFactory"/>
           -->
            <filter class="solr.PorterStemFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="5"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.StopFilterFactory"
               ignoreCase="true"
               words="stopwords_en.txt"
               enablePositionIncrements="true"
               />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
            <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
            <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
               <filter class="solr.EnglishMinimalStemFilterFactory"/>
           -->
            <filter class="solr.PorterStemFilterFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
        <analyzer>
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="ngram" class="solr.TextField" >
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="15" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>

    <fieldType name="edge_ngram" class="solr.TextField" positionIncrementGap="1">
        <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
            <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front" />
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
        </analyzer>
    </fieldType>
</types>

    <fields>
        <!-- general -->
        <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
        <field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/>
        <field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>

    <dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
    <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
    <dynamicField name="*_l"  type="long"   indexed="true"  stored="true"/>
    <dynamicField name="*_t"  type="text_en"    indexed="true"  stored="true"/>
    <dynamicField name="*_b"  type="boolean" indexed="true"  stored="true"/>
    <dynamicField name="*_f"  type="float"  indexed="true"  stored="true"/>
    <dynamicField name="*_d"  type="double" indexed="true"  stored="true"/>
    <dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
    <dynamicField name="*_p" type="location" indexed="true" stored="true"/>
    <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false"/>


    <field name="type" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="description" type="date" indexed="true" stored="true" multiValued="false" />

    <field name="title" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="text" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="is_completed" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="place_of_work" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="personal_characteristics" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="responsibilities" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="work_experience" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="educational_level" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="owner" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="is_verified" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="amount_of_vacancies" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="annual_turnover" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="local_shareholding" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="number_of_employees" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="collaboration" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="user" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="name" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="end_date" type="date" indexed="true" stored="true" multiValued="false" />

    <field name="field_of_study" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="degree_awarded" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="awarding_institution" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="location" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="technical_skills" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="start_date" type="date" indexed="true" stored="true" multiValued="false" />

    <field name="email_personal" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="first_name" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="last_name" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="phone_work" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="skills" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="email_work" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="address_home" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="address_office" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="self_description" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="date_of_birth" type="date" indexed="true" stored="true" multiValued="false" />

    <field name="country_of_birth" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="phone_personal" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="nationality" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="collaboration_projects" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="cv" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="industry" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="job_summary" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="company_name" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="courses_taken" type="text_en" indexed="true" stored="true" multiValued="false" />

    <field name="job_title" type="text_en" indexed="true" stored="true" multiValued="false" />

    </fields>

    <!-- field to use to determine and enforce document uniqueness. -->
    <uniqueKey>id</uniqueKey>

    <!-- field for the QueryParser to use when an explicit fieldname is absent -->
    <defaultSearchField>text</defaultSearchField>

    <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
    <solrQueryParser defaultOperator="AND"/>
</schema>

任何帮助将不胜感激!

4

1 回答 1

1

感谢 Alexandre Rafalovitch,他的评论为我指明了正确的方向。

事实证明,supervisor 在没有报告任何错误的情况下启动和停止 solr。当我手动启动 solr 时,我会看到它无法启动,因为该端口已被占用。

这意味着,我在不知不觉中遗漏了最重要的信息:我在一个共享托管环境中工作,另一个用户已经设置了他自己的 solr 实例。

为了进一步验证我确保主管和“我的”solr 实例已停止。然后我跑了

curl http://localhost:8983/solr

我得到了回应。

现在事情很容易。我改变了端口

~/opt/apache-solr-3.5.0/example/etc/jetty.xml

在我的 Django 项目8984local_settings.py,我添加了以下内容:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8984/solr'
    },
}

等等。现在我可以再次重建我的索引。

于 2013-03-27T00:38:27.427 回答