首页 \ 问答 \ Solr返回JSON(JSON returned by Solr)

Solr返回JSON(JSON returned by Solr)

我正在使用Solr来索引我的数据。

通过Solr的UI,我在Schema窗口中添加了两个字段:word,messageid

我做了以下查询帖子后:

curl -X POST -H "Content-Type: application/json" 'http://localhost:8983/solr/messenger/update.json/docs' --data-binary '{"word":"hello","messageid":"23523}'

我收到了以下JSON:

{
  "responseHeader": {
    "status": 0,
    "QTime": 55
  }
}

当我要进入API中的查询窗口并执行不带参数的查询时,我得到以下JSON:

{
  {
    "responseHeader": {
      "status": 0,
      "QTime": 0,
      "params": {
        "q": "*:*",
        "indent": "on",
        "wt": "json",
        "_": "1488911768817"
      }
    },
    "response": {
      "numFound": 1,
      "start": 0,
      "docs": [
        {
          "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
          "_src_": "{\"word\":\"hello\",\"messageid\":\"23523\"}",
          "_version_": 1561232739042066432
        }
    }
  }
}

我的JSON不应该更像下一个吗?:

//More Code
"response": {
  "numFound": 1,
  "start": 0,
  "docs": [
    {
      "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
      "word": "hello",
      "messageid": "23523",
      "_version_": 1561232739042066432
    }
//More Code

为了以后能够通过以下选项使用参数进行过滤?:

在此处输入图像描述


I'm using Solr in order to index my data.

Through the Solr's UI I added, in the Schema window, two fields: word, messageid

After I made the following query post:

curl -X POST -H "Content-Type: application/json" 'http://localhost:8983/solr/messenger/update.json/docs' --data-binary '{"word":"hello","messageid":"23523}'

I received the following JSON:

{
  "responseHeader": {
    "status": 0,
    "QTime": 55
  }
}

When I'm going to the Query Window in the API and Execute a query without parameters I get the following JSON:

{
  {
    "responseHeader": {
      "status": 0,
      "QTime": 0,
      "params": {
        "q": "*:*",
        "indent": "on",
        "wt": "json",
        "_": "1488911768817"
      }
    },
    "response": {
      "numFound": 1,
      "start": 0,
      "docs": [
        {
          "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
          "_src_": "{\"word\":\"hello\",\"messageid\":\"23523\"}",
          "_version_": 1561232739042066432
        }
    }
  }
}

Shouldn't my JSON appear more like the following one?:

//More Code
"response": {
  "numFound": 1,
  "start": 0,
  "docs": [
    {
      "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
      "word": "hello",
      "messageid": "23523",
      "_version_": 1561232739042066432
    }
//More Code

In order to be able later on to filter using parameters through the following option?:

enter image description here


原文:https://stackoverflow.com/questions/42655951
更新时间:2022-03-24 06:03

最满意答案

您可以使用协议和协议扩展将相同的功能注入到这两个类中:

@objc protocol MyProto {
    func someFunc()
}
extension MyProto {
    func someFunc() {
        print("howdy")
    }
}
class MyTableViewCell : UITableViewCell, MyProto {
}
class MyCollectionViewCell : UICollectionViewCell, MyProto {
}
let cell1 = MyTableViewCell()
cell1.someFunc() // "howdy"
let cell2 = MyCollectionViewCell()
cell2.someFunc() // "howdy"

...显示他们都做同样的事情,而不重复代码。


You can inject identical functionality into both class using a protocol plus a protocol extension:

@objc protocol MyProto {
    func someFunc()
}
extension MyProto {
    func someFunc() {
        print("howdy")
    }
}
class MyTableViewCell : UITableViewCell, MyProto {
}
class MyCollectionViewCell : UICollectionViewCell, MyProto {
}
let cell1 = MyTableViewCell()
cell1.someFunc() // "howdy"
let cell2 = MyCollectionViewCell()
cell2.someFunc() // "howdy"

...showing that they both do the same thing, without repetition of the code.

相关问答

更多
  • 这是一个标签声明 。 你可以用goto , break或continue使用它。 来自docs : 定义从未使用过的标签是非法的。 与其他标识符相比,标签不是块作用域,也不与非标签的标识符冲突。 标签的范围是声明它的函数体,并排除任何嵌套函数的主体。 它们在您需要以某种方式更改流量的情况下非常有用,即。 K: for i:=0; i<10; i++ { for j:=0; j<10; j++{ if (somefunction(j)) { continue K ...
  • 执行此操作的常用方法是在UserControl中包含GridView 如果将网格放在用户控件上,并订阅那里的所有事件,那么您可以在应用程序中的任何位置重用此实现 - 您实际上只是使用所需的功能包装用户控件,然后重用此包装器到处。 巧妙的是你只需编写一次连线代码。 这就是我认为你想做的事情。 但是,如果要在usercontrol之外扩展或处理这些事件,则需要重新实现它们(即添加自己的事件处理程序并让它们冒泡)。 但是,您不能强迫任何人订阅您的活动。 如果要强制执行事件,则可以将事件放在接口上,并在类或控件上实 ...
  • 首先,公开继承std::vector和其他标准库容器被认为是个坏主意 。 记住这一点,从另一个类模板继承的类模板所需的语法是 template class NewVector : public vector { // .... }; First of all, publicly inheriting from std::vector and other standard library containers is considered a bad idea. Keeping t ...
  • 虚拟只在需要运行时多态性的地方使用。 使用虚拟方法确保方法的正确版本(BASE / DERIVED)得到调用,并且根据调用者对象的类型在运行时解析调用。 有关更多参考虚拟功能 和YES,你的理解是正确的。 Virtual is used only where runtime polymorphism is needed. Use of virtual make sure that correct version (BASE/DERIVED) of the method is getting called a ...
  • 问题是当你定义类prod和声明函数bind时 virtual module& bind(mixer &mix); 在类范围中,您隐藏了具有相同基类名称的所有其他函数。 那么你打来电话 prod1.bind(prod2); 编译器在类范围中只看到一个候选者:上面显示的函数。 并且它无法将参考产品转换为参考混频器。 你应该写在类定义中 using in_out::bind; 正如@Alex在他的评论中指出的那样,如果你使用多态,你必须使类模块的析构函数成为虚拟。 编辑:如果要将pfn_inout替换为in ...
  • 将Symbol.species设置为原始Array构造函数可修复此问题 class Pipeline extends Array { static get [Symbol.species]() { return Array; } // ... } 编辑 : Array.prototype.filter实现不会改变原始对象,而是创建一个新的对象来存储结果。在这种情况下,派生的构造函数用于此,它在每个init上使用正好2个值填充对象。 您可以在派生类上设置Symbol.species以专门告 ...
  • 根据您上面给出的解释,继承通用图表是不正确的。 继承是一种工具,可帮助将具有其他属性,方法和功能的相同类型的现有类扩展为一个类。 因此,如果您要做的就是通过指定边和权重的类型来获取通用图并使其成为特定图,而不向原始类的结构或功能添加任何其他内容,则继承是不必要的。 话虽如此,有很多情况下,人们可能需要继承模板类,并根据手头的任务将其保留为通用模板类或特定模板类。 例如,如果您被赋予创建一个类的任务,该类表示列表上的常规操作的整数列表,另外还要实现一个返回的函数(假设这些数字的平均值或任何其他不支持的操作)由 ...
  • 您可以使用协议和协议扩展将相同的功能注入到这两个类中: @objc protocol MyProto { func someFunc() } extension MyProto { func someFunc() { print("howdy") } } class MyTableViewCell : UITableViewCell, MyProto { } class MyCollectionViewCell : UICollectionViewCell, MyPr ...

相关文章

更多

最新问答

更多
  • 您如何使用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)