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 8410293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:08:14+00:00 2026-06-10T00:08:14+00:00

I have Player and Player have fullname from Profil. I use elasticsearch on Player.

  • 0

I have Player and Player have fullname from Profil. I use elasticsearch on Player. I need default sort by fullname. How can I set it? My code from Player class file:

   ......
  mapping do
    indexes :id, type: 'integer'
    indexes :fullname, boost: 10
    indexes :name
    indexes :surname
    indexes :position_name
    indexes :info
    indexes :club_id, type: 'integer'
    indexes :club_name
  end

  def self.search(params)
    tire.search(load: true, page: params[:page], per_page: 20) do
      query do
        boolean do
          if params[:query].present?
            must { string params[:query], default_operator: "AND" } 
          else
            must {string '*'}
          end
          must { term :position_id, params[:position_id]} if params[:position_id].present?
          must { term :club_id, params[:club_id]} if params[:club_id].present?
        end
      end
      # filter :term, user_id: params[:user_id] if params[:user_id].present?
      # sort { by Item.column_names.include?(params[:sort]) ? params[:sort] : "created_at", %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc" } if params[:query].blank?

      sort { by Player.column_names.include?(params[:sort]) ? params[:sort] : :id ,%w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"}
      facet "positions" do
        terms :position_id
      end
      facet "clubs" do
        terms :club_id
      end
      # raise to_curl
    end
  end

  def to_indexed_json
    to_json(methods: [:fullname, :name, :surname, :position_name, :club_name])
  end

  def fullname
        self.profil.fullname
  end
......

If I changed :id to :fullname in sort I have this error:

500 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[DBgvi6JiQAi0FTwhonq8Ag][players][0]: QueryPhaseExecutionException[[players][0]: query[ConstantScore(NotDeleted(cache(_type:player)))],from[0],size[20],sort[<custom:\"fullname\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@33a626ac>!]: 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]; }{[DBgvi6JiQAi0FTwhonq8Ag][players][4]: QueryPhaseExecutionException[[players][4]: query[ConstantScore(NotDeleted(cache(_type:player)))],from[0],size[20],sort[<custom:\"fullname\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@3274eb8a>!]: 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]; }]","status":500}
  • 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-10T00:08:15+00:00Added an answer on June 10, 2026 at 12:08 am

    I got it! After dumb amounts of research I found this article here. The first answer mentions:

    The field user by default gets analyzed and broken down into one or more tokens. If it gets broken down into more than one token, then you can’t really sort on it. If you want to sort on it, you either need to set it i(in the mappings) as not analyzed

    In your situation, all you would need to do is:

     mapping do
        indexes :id, type: 'integer'
        indexes :fullname, :index => 'not_analyzed'
        indexes :name
        indexes :surname
        indexes :position_name
        indexes :info
        indexes :club_id, type: 'integer'
        indexes :club_name
      end
    

    And it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Switched from XmlTextWriter to XElement I have a Player class, which has following
I have a Player class that derives from Humanoid and Humanoid derives from Sprite
This is my problem: I have a player class and SwipeDetector Class in c#,
I have a baseball player super class I have a left field, center field,
I have a flash player that loads in some additional features from flash files
So, i'm attempting simple card game. I have player class with draw function, and
I have this Player class which implements the Comparable interface. Then I have an
Say as an example I have a Player class that has a race via
I'm building a game, and for my players I have a player class. This
I have a player class and viewmodel class Player constructor: -> @boat = ko.observable

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.