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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:58:05+00:00 2026-06-10T03:58:05+00:00

I have a query in standard JSON format that works pretty fine when queried

  • 0

I have a query in standard JSON format that works pretty fine when queried directly from command line. The json is:

{"fields" : ["id"],
 "query":{
    "bool":{
      "must":[
        {
          "custom_score" : {
              "query" : {
                "bool" : {
                  "should" : [
                    {
                      "term" : {"a.in.group" : "abcd"}
                    },
                    {
                      "term" : {"a.in.group": "ALL"}
                    }
                   ]
                 }
              },
            "boost" : 1.0,
            "script" : "_score"
            }
        },

        {
          "custom_score" : {
              "query" : {
                "bool" : {
                  "should" : [
                    {
                      "term" : {"b.in.prefix" : pre}
                    },
                    {
                      "term" : {"b.in.group" : "abc"}
                    }
                   ]
                 }
              },
            "boost" : 1.0,
            "script" : "_score"
            }
        }
       ]
      }
    }
}

This is giving me result as desired:

curl -X GET "localhost:9200/test/rule/_search" -d @query.json
{"took":6,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":2.3251607,"hits":[{"_index":"memphis","_type":"rule","_id":"1","_score":2.3251607,"fields":{"id":1}}]}}

But I am unable to find the right syntex for the equivalent tire query. I tried:

s=Tire.search('test/rule') do
    query do
        boolean do
            must [
                query do
                    boolean do
                        should { string "a.in.group:abcd" }
                        should { string "a.in.group:ALL" }
                    end
                end
                query do
                    boolean do
                        should { string "b.in.prefix:pre" }
                        should { string "b.in.group:abc" }
                    end
                end
            ]
        end
    end

    fields :id
end

But this is giving me syntax error:

ruby -c query.rb 
query.rb:7: syntax error, unexpected keyword_do_block, expecting ']'
query.rb:19: syntax error, unexpected ']', expecting keyword_end
query.rb:46: syntax error, unexpected $end, expecting keyword_end

I couldn’t find any help on any other forum. Problem occurs when I try to put multiple queries in the must block. Please help.

Thanks in Advance

-Azitabh

  • 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-10T03:58:06+00:00Added an answer on June 10, 2026 at 3:58 am

    See if this will do the trick:

    s = Tire.search 'test/rule' do
        query do
          boolean do
              must do
                  custom_score :boost => 1.0, :script => "_score" do
                    boolean do
                        should { term 'a.in.group', "abcd" }
                        should { term 'a.in.group', "ALL" }
                    end
                  end
              end
              must do
                  custom_score :boost => 1.0, :script => "_score" do
                    boolean do
                        should { term 'b.in.prefix', pre }
                        should { term 'b.in.group', "abc" }
                    end
                  end
              end
          end
        end
        fields :id
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using in C# MYsql .I have query that works if I run
I have a query that successfully grabs the unique products from my products table
I have a standard query that gets the current user object: @user = User.find_by_email(session[:email])
I have query like this: SELECT *, SUM(ss.rank) as group_sum FROM Standard s, s.SubStandard
I have a query that is basically like this: SELECT foo FROM bar where
So I have a fairly standard LINQ-to-Object setup. var query = expensiveSrc.Where(x=> x.HasFoo) .OrderBy(y
I have query like this : SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS
I have a query in Access 2007. It's worked fine for months, but I'm
I have this query which does work fine in MySQL SELECT ((ACOS(SIN(12.345 * PI()
I have a query stored in MS Access which is doing a standard select

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.