我想知道是否有可能对包含可解码的JSON字符串的数据进行索引,并将每个JSON值与各个值进行索引。Solr - 从数据库索引JSON查询字符串?
我使用DIH连接到MySQL数据库并能够索引各个列。 结果将如下所示:
<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>
的问题是,“活动促销”是,我想解码,并有一些像我的指标以下JSON字符串:
<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可以做到这一点吗?
在此先感谢
JSON的结构是否固定?即它是否总是有三个名为'day','year'和'month'的键?以相同的顺序? – Chewie
不是一个答案,而是一个想法。您可能不想将数据以JSON格式存储在数据库中。不得不问这个问题只是一个例子,为什么不呢。数据库不是你的演示文稿应该被保留的地方,特别是如果你真的需要访问单个字段。日期应该存储在支持它的数据库字段类型中。你最好希望你永远不需要排序,或者按照这个日期选择。你刚刚证明有人想要搜索它。 – rfeak