Solr - 从数据库索引 JSON 查询字符串? [英] Solr - index JSON query string from database?

查看:91
本文介绍了Solr - 从数据库索引 JSON 查询字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以索引包含可以解码的 JSON 字符串的数据,并且每个 JSON 值都可以使用单独的值进行索引.

I would like to know if it is possible to index data that contains a JSON string that can be decoded and each JSON value to be indexed with the separate values.

我使用 DIH 连接到 MySQL 数据库并能够索引各个列.结果如下所示:

I am using the DIH to connect to a MySQL database and able to index the individual columns. The result would look like the following:

<response name="response" numFound="1" start="0" maxScore="2.7143538">
    ...
    <result name="response" numFound="1" start="0" maxScore="2.7143538">
        <doc>
        <float name="score">2.7143538</float>
        <str name="id">82</str>
        <str name="name">jorge</str>
        <str name="otherinfo">{"day":15,"year":1989,"month":"January"}</str>
    </doc>
</result>
</response>

问题是otherinfo"是一个 JSON 字符串,我想对其进行解码并在我的索引中包含以下内容:

The problem is that "otherinfo" is a JSON string that I would like to decode and have something like the following in my index:

<response name="response" numFound="1" start="0" maxScore="2.7143538">
    ...
    <result name="response" numFound="1" start="0" maxScore="2.7143538">
        <doc>
        <float name="score">2.7143538</float>
        <str name="id">82</str>
        <str name="name">jorge</str>
        <str name="day">15</str>
        <str name="year">1989</str>
        <str name="month">January</str>
    </doc>
</result>
</response>

这完全可以通过 Solr 实现吗?

Would this be possible to do at all with Solr?

提前致谢

推荐答案

我对此发表了评论.我决定我应该回答.

I commented on this. I decided that I should answer instead.

您的问题的修复不在 Solr 级别.一开始,您不应该以这种方式将数据存储在数据库中.从长远来看,最好在那里解决这个问题,而不是试图在 Solr 索引级别解决这个问题.

The fix for your issue isn't at the Solr level. You shouldn't be storing your data this way in the DB to begin with. In the long run, it would be better to fix this problem there, as opposed to trying to hack this at the Solr indexing level.

您的问题证明有人(可能是最终用户)有兴趣通过此数据进行搜索.这意味着它可能应该作为实际的日期或时间戳字段存储在数据库中,以便可以正确选择或排序.

Your question proves that someone, probably an end user, is interested in searching by this data. This implies that it should probably be stored in the database as an actual Date or Timestamp field so that it can be properly selected or sorted on.

我敢肯定人们不会喜欢这并不能完全回答您的问题,但需要有人告诉您这一点.

I'm sure people won't like that this doesn't exactly answer your question, but someone needs to tell you this.

这篇关于Solr - 从数据库索引 JSON 查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆