全文搜索 JSON-string

Full-text searth JSON-string

我有一个问题:在我的数据库中,我有一个 table,他有一个带有 JSON-string 的字段,例如: 字段 "description"

{
solve_what: "Add project problem",
solve_where: "In project CRUD",
shortname: "Add error"
}

如何全文搜索这个字符串?例如,我需要找到在 description.solve_what 中具有“project” 的所有记录。在我的 sphinx.conf 我有

sql_attr_json = description

P.S.Mb 我可以用 elasticSearch 做到这一点吗?

我刚刚在这里回答了一个非常相似的问题: http://sphinxsearch.com/forum/view.html?id=13861

Note there is no support for extracting them as FIELDs at this time - so cant 'full-text' search the text within the json elements.

(To do that would have to use mysql string manipulation functions to create a new column to index as a normal field. Something like:

SELECT id, SUBSTR(json_column, LOCATE('"tag":"', json_column)+7, LOCATE('"', json_column, LOCATE('"tag":"', json_column)+7)-LOCATE('"tag":"', json_column)-7 ) AS tag, ...

is messy but should work... )

代码未经测试。