Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8558481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:49:17+00:00 2026-06-11T15:49:17+00:00

I notice that running rebuild_index from the Python shell causes problems with sorting. Running

  • 0

I notice that running rebuild_index from the Python shell causes problems with sorting. Running rebuild_index from Bash does the right thing.

$ bin/manage rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y

Removing all documents from your index because you said so.
Failed to clear Elasticsearch index: Non-OK status code returned (404) containing u'IndexMissingException[[my_index] missing]'.
All documents removed.
Indexing 40 components.

—

In [1]: from haystack.query import SearchQuerySet

In [2]: SearchQuerySet().order_by('name')
Out[2]: [<SearchResult: my_app.component (pk=u'2')>, <SearchResult: my_app.component (pk=u'1')>, <SearchResult: my_app.component (pk=u'5')>, <SearchResult: my_app.component (pk=u'4')>, <SearchResult: my_app.component (pk=u'3')>, <SearchResult: my_app.component (pk=u'6')>, <SearchResult: my_app.component (pk=u'7')>, <SearchResult: my_app.component (pk=u'8')>, <SearchResult: my_app.component (pk=u'9')>, <SearchResult: my_app.component (pk=u'11')>, <SearchResult: my_app.component (pk=u'14')>, <SearchResult: my_app.component (pk=u'13')>, <SearchResult: my_app.component (pk=u'15')>, <SearchResult: my_app.component (pk=u'19')>, <SearchResult: my_app.component (pk=u'20')>, <SearchResult: my_app.component (pk=u'21')>, <SearchResult: my_app.component (pk=u'22')>, <SearchResult: my_app.component (pk=u'23')>, <SearchResult: my_app.component (pk=u'24')>, '...(remaining elements truncated)...']

In [3]: from django.core import management

In [4]: management.call_command('rebuild_index', interactive=False, verbosity=0)
Failed to clear Elasticsearch index: Non-OK status code returned (404) containing u'IndexMissingException[[my_index] missing]'.

In [5]: SearchQuerySet().order_by('name')
Failed to query Elasticsearch using '*:*': Non-OK status code returned (500) containing u'SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[SkgxFvdjRgyoiHv2qSpfbQ][my_index][4]: QueryPhaseExecutionException[[my_index][4]: query[filtered(ConstantScore(NotDeleted(cache(QueryWrapperFilter(django_ct:my_app.component)))))->cache(_type:modelresult)],from[0],size[20],sort[<custom:"name": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@3cb9b947>]: Query Failed [Failed to execute main query]]; nested: IOException[Can\'t sort on string types with more than one value per doc, or more than one token per field]; }{[SkgxFvdjRgyoiHv2qSpfbQ][my_index][0]: QueryPhaseExecutionException[[my_index][0]: query[filtered(ConstantScore(NotDeleted(cache(QueryWrapperFilter(django_ct:my_app.component)))))->cache(_type:modelresult)],from[0],size[20],sort[<custom:"name": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@249cf580>]: Query Failed [Failed to execute main query]]; nested: IOException[Can\'t sort on string types with more than one value per doc, or more than one token per field]; }{[SkgxFvdjRgyoiHv2qSpfbQ][my_index][3]: QueryPhaseExecutionException[[my_index][3]: query[filtered(ConstantScore(NotDeleted(cache(QueryWrapperFilter(django_ct:my_app.component)))))->cache(_type:modelresult)],from[0],size[20],sort[<custom:"name": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@4ff80724>]: Query Failed [Failed to execute main query]]; nested: IOException[Can\'t sort on string types with more than one value per doc, or more than one token per field]; }{[SkgxFvdjRgyoiHv2qSpfbQ][my_index][2]: QueryPhaseExecutionException[[my_index][2]: query[filtered(ConstantScore(NotDeleted(cache(QueryWrapperFilter(django_ct:my_app.component)))))->cache(_type:modelresult)],from[0],size[20],sort[<custom:"name": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@99b8b51>]: Query Failed [Failed to execute main query]]; nested: IOException[Can\'t sort on string types with more than one value per doc, or more than one token per field]; }{[SkgxFvdjRgyoiHv2qSpfbQ][my_index][1]: QueryPhaseExecutionException[[my_index][1]: query[filtered(ConstantScore(NotDeleted(cache(QueryWrapperFilter(django_ct:my_app.component)))))->cache(_type:modelresult)],from[0],size[20],sort[<custom:"name": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@42d777c4>]: Query Failed [Failed to execute main query]]; nested: IOException[Can\'t sort on string types with more than one value per doc, or more than one token per field]; }]'.
Out[5]: []

I inspected the index metadata using the elasticsearch-head frontend. I found that the settings structure was different depending on which shell I ran rebuild_index from.

The good version (rebuild_index run from Bash):

settings: {
index.analysis.filter.haystack_ngram.type: nGram
index.analysis.tokenizer.haystack_edgengram_tokenizer.type: edgeNGram
index.analysis.analyzer.edgengram_analyzer.filter.0: haystack_edgengram
index.analysis.filter.haystack_edgengram.min_gram: 2
index.analysis.tokenizer.haystack_edgengram_tokenizer.side: front
index.analysis.filter.haystack_edgengram.type: edgeNGram
index.analysis.filter.haystack_ngram.max_gram: 15
index.analysis.analyzer.edgengram_analyzer.type: custom
index.analysis.tokenizer.haystack_ngram_tokenizer.max_gram: 15
index.analysis.tokenizer.haystack_ngram_tokenizer.type: nGram
index.analysis.tokenizer.haystack_edgengram_tokenizer.max_gram: 15
index.analysis.tokenizer.haystack_edgengram_tokenizer.min_gram: 2
index.analysis.analyzer.ngram_analyzer.filter.0: haystack_ngram
index.analysis.analyzer.ngram_analyzer.tokenizer: lowercase
index.analysis.tokenizer.haystack_ngram_tokenizer.min_gram: 3
index.analysis.filter.haystack_ngram.min_gram: 3
index.analysis.analyzer.ngram_analyzer.type: custom
index.analysis.analyzer.edgengram_analyzer.tokenizer: lowercase
index.analysis.filter.haystack_edgengram.max_gram: 15
index.number_of_shards: 5
index.number_of_replicas: 1
index.version.created: 190999
}

The bad version (rebuild_index run from the Python shell):

settings: {
index.number_of_shards: 5
index.number_of_replicas: 1
index.version.created: 190999
}

What are all those index.analysis.* keys? Where do they come from?

Haystack ticket: https://github.com/toastdriven/django-haystack/issues/645

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:49:18+00:00Added an answer on June 11, 2026 at 3:49 pm

    This happens because instance variables in the backend need to be reset before running rebuild_index a second time.

    from django.core import management
    from haystack import connections
    backend = connections['default'].get_backend()
    backend.setup_complete = False
    backend.existing_mapping = None
    management.call_command('rebuild_index', interactive=False, verbosity=0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I notice strange behavior when running the the rebuild_index command multiple times from one
I'm running some MASM32 examples (from www.masm32.com) and I notice that the console output
I've noticed that running this subquery SELECT ST_Area(ST_Union(ST_Transform(ST_Intersection((SELECT poly1.the_geom from poly1 WHERE poly1.polygon_type='P'),poly2.the_geom),3857))) AS
I notice that sometimes when I try to override a CSS rule, browser does
I notice that Growl allows for the possibility of Growl notifications from a website.
If you are running Windows with a higher DPI setting you will notice that
I'm running VS2010, debugging as normal, and suddenly I notice that my code changes
I have my NodeJS and Socket.IO server running perfectly, however I notice that a
Back story: While running a program under strace I notice that '/dev/urandom' is being
I'm running into a server notice that doesn't seem to effect the loading of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.