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

  • SEARCH
  • Home
  • 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 8679377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:57:23+00:00 2026-06-12T20:57:23+00:00

I have mapped an associated field as a multi-field. I have set the ‘name’

  • 0

I have mapped an associated field as a multi-field. I have set the ‘name’ property to be analyzed using a snow ball analyzer and ‘exact’ as not analyzed. I am able to search on this field and filter as well. I am not able to sort on this field. When trying to sort, elastic returns an error “Can’t sort on string types with more than one value per doc, or more than one token per field”.

I have attempted creating an additional field called ‘raw’ similar to exact, and this did not work either. Below is my mapping and how I am attempting to perform the sort via the tire gem:

    mapping do
    indexes :sectors, :type => 'object',
      :properties => { :name => { :type => 'multi_field',
                                  :fields => {
                                    :name =>  { :type => 'string', :analyzer => 'snowball' },
                                    :exact => { :type => 'string', :index => 'not_analyzed' , :include_in_all => false }
                                  }
                                  }
                       }
end

def to_indexed_json
    to_json( :include => {
               ...
               :sectors => { :only => ["name"] },
               ...
    })
end

def self.search(params)
  tire.search(:load => true, :page=>params[:page], :per_page => 12) do

    if params[:query].present?
      query { string params[:query], :default_operator => "OR" }
    else
      query { all }
    end

    filter :term, "sectors.name.exact" => params[:sector] if params[:sector].present?
    sort { by 'sectors.name.exact','asc' } if !params[:sort][:sector].blank?
  end
end
  • 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-12T20:57:25+00:00Added an answer on June 12, 2026 at 8:57 pm

    There are basically two reasons why you’re getting that error:

    • You have more than one value per field: your field is analyzed and the tokenizer produces multiple tokens out of its content, which is not the case with your name.exact field since it’s not_analyzed in your mapping
    • You have more than one value per document: you’re adding multiple values to the name field, for example providing an array of values while indexing.

    I would check what your documents look like. In order to do it quickly you can make a Terms Facet based on a script which returns the number of items included in the name.exact field like the following. If you get back at least one of the facet entries with term greather than 1, it means that you’ve added multiple values to the field at least once, thus you cannot sort on it.

    {
        "query" : {
            "match_all" : {}
        },
        "facets" : {
            "my_facet" : {
                "terms" : {
                    "script_field" : "doc['name.exact'].values.length"
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables associated by FK. Table student is mapped like this: @Entity
I m able to get values using JPA when i have only mapped one
I have an entity mapped as following: @Entity @Table(name = Groups) @IdClass(value = GroupId.class)
I have mapped class, that have ID with custom type <id name=idPersistent type=objectID column=aa_id
I have an object that is mapped to have a set of objects, very
I have an entity User mapped in playORM. This entity has an embedded field:
I have mapped the database in the edmx file from the database. Now how
I have mapped a network drive to a computer in my home network. Now
Two Windows processes have memory mapped the same shared file. If the file consists
I have a table called Person which I have already mapped in hibernate I

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.