首页 \ 问答 \ 如何使用elasticsearch进行排序?(How to sort with elasticsearch?)

如何使用elasticsearch进行排序?(How to sort with elasticsearch?)

我正在尝试制作排序descasc 。 我正在使用rails,tire gem和elasticsearch。 我试图弄清楚我可以在URL中发送什么类型的参数

所以我在搜索块中定义它正在对结果desc顺序进行排序。

sort { by :price, "desc"}

当用户在: new-york中搜索公寓时,结果是排序顺序。

搜索查询/ URL如下所示:

http://localhost:3000/apartmens?utf8&query=newyork

为什么我不能在网址中添加sort-params,如下所示:

http://localhost:3000/apartmens?utf8&query=newyork&sort=asc

I am trying to make methods for sorting desc and asc. I am using rails, tire gem and elasticsearch. I am trying to figure out what sort params I can send in the URL

So I have defined in the search-block that it is sorting the result desc order.

sort { by :price, "desc"}

When a user search for apartments in: new-york the result is sort desc order.

The search query/URL looks like this:

http://localhost:3000/apartmens?utf8&query=newyork

Why cant I add a sort-params in the url, like this:

http://localhost:3000/apartmens?utf8&query=newyork&sort=asc

原文:https://stackoverflow.com/questions/14756149
更新时间:2022-07-28 22:07

最满意答案

thread.start_new_thread返回线程标识符,而不是thread.start_new_thread本身。 所以你实际上附加了整数的胎面标识符。

您可以创建并启动一个Thread对象(为此您需要从线程中导入Thread),然后您将获得对它的引用

例如:

t = Thread(target=your_target, args=your_args)
t.start()
threads.append(t)

thread.start_new_thread returns the thread identifier, not the tread itself. So you are actually appending the tread identifiers which are integers.

You could create and start a Thread object (for that you need to import Thread from threading) then you would have a reference to it

Ex:

t = Thread(target=your_target, args=your_args)
t.start()
threads.append(t)

相关问答

更多
  • 使用push()函数附加到数组: // initialize array var arr = [ "Hi", "Hello", "Bonjour" ]; // append new value to the array arr.push("Hola"); console.log(arr); 会打印 ["Hi", "Hello", "Bonjour", "Hola"] 您可以使用push()函数在单个调用中将多个值附加到数组: // initialize ar ...
  • 您可以使用json.loads解析JSON,执行操作,然后通过json.dumps转换回JSON。 请注意,我必须编辑您的JSON才能使其有效。 (“Gateway”缺少封闭的双引号。) import json values = [20.8, 21.2, 22.4] timeStamps = ["2013/25/11 12:23:20", "2013/25/11 12:25:20", "2013/25/11 12:28:20"] myJSON = '{ "Gateway": {"serial":"1 ...
  • thread.start_new_thread返回线程标识符,而不是thread.start_new_thread本身。 所以你实际上附加了整数的胎面标识符。 您可以创建并启动一个Thread对象(为此您需要从线程中导入Thread),然后您将获得对它的引用 例如: t = Thread(target=your_target, args=your_args) t.start() threads.append(t) thread.start_new_thread returns the thread ide ...
  • 一步一步。 理想情况下,您应该确定响应不同的原因。 由于您说这些差异通常与您的请求中的不同内容相对应,因此强烈建议您可能忽略(或可能误解)远程API中的某些内容。 我建议重新审核API以识别“某些东西”,以便找出正确的方法。 否则,当您继续调整代码以处理每个“新”情况时,代码将很快变得难以管理且效率低下。 如果出于某种原因,API确实在没有正当理由的情况下返回不同的结果,那么您可以做的最好的事情是根据您的期望进行编码,并在收到其他内容时优雅地失败。 首先列出预期的可能性: 响应是包含某些键OR的单个结构 R ...
  • 您可能需要将数组定义为包含可变数组,如下所示。 var returnObject = [NSMutableArray]() 你也可以使用一个Swift'sub'数组,并将它定义为更像这样。 var returnObject = Array>() 不要忘记更新方法的回报。 func getJSON() -> Array> You may need to define the array as containing a mutable array a ...
  • 在为结构或类定义接口时,可以执行的操作类型存在限制。 您可以对值进行一些基本的初始化,但不允许调用append()等方法。 这是对代码的快速调整,我将附加内容移动到init()方法中: struct Toolkit { var tools = [ [ "name": "Know Yourself to Lead Yourself", "shape": "icon_knowyourself.pdf", "image": "know_yourself_to ...
  • 问题中的代码是不安全的,因为它在一个goroutine中读取变量并在没有同步的情况下修改另一个goroutine中的变量。 这是使代码安全的一种方法: type Obj struct { mu sync.Mutex // add mutex ... // other fields as before } func (o *Obj) Reader() { o.mu.Lock() data := o.data o.mu.Unlock() for i, value : ...
  • 问题并不完全清楚,但如果我理解正确,可以提供一个可以接受或不接受前一个Block的类。 你觉得那样的事怎么样? #!/usr/bin/env ruby class Block < Hash def initialize(h, b=nil) [:x, :y, :z].each do |s| # We start by trying to assign the coordinate that is in the # input hash if h[s] ...
  • 这是关于值类型与引用类型的常见混淆,来自Java或C ++背景。 当您将用户的内容分配给本地变量user ,然后在样本底部变异该变量时,您只需要修改本地副本。 将用户更改为一个class ,所有都可以。 从风格上讲,如果您在代码中使用强制解包,则还应该在底部使用强制解包,因为您不希望它以静默方式失败。 或者,保持结构,但在完全变异之前不要将user放入users 。 This is the usual confusion about value types versus reference types, c ...
  • 您无法修改表中的数据,因为ClickHouse中的所有数据都是不可变的。 但是 :您可以在选择期间即时添加,或者您可以制作一个VIEW,它将为您完成。 如果您确实需要以更改状态存储该列 - 您需要创建表副本或物化视图。 这些函数可以是有用的arrayConcat,arrayPushBack,arrayPushFront(文档即将发布)。 所以 SELECT CASE WHEN condition > 10 THEN arrayPushBack(array_field, 'extra_elemen ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)