0

可以对以下 solr 集合执行查询

{
    "id":1,
    "book_name":"Solr book",
    "category":[1,2,3],
    "author":[1]
},
{
    "id":1,
    "book_name":"Rocky",
    "category":[3],
    "author":[2]
},
{
    "category_id": 1,
    "category_name":"Technology"
},
{
    "category_id": 2,
    "category_name":"Apache Lucene"
},
{
    "category_id": 3,
    "category_name":"Sport"
},
{
    "author_id": "1",
    "author_name" "Chuck Norris"
},
{
    "author_id": "1",
    "author_name" "John Rambo"
}

这将返回类似:

{
    "id": 1,
    "book_name": "Solr book",
    "categories": ["Technology", "Apache Lucene"],
    "Authors": ["Chuck Norris"]
}

在典型的搜索框输入中按 book_name AND/OR category_name AND/OR author name 搜索?或替代响应,我会返回类似的东西?

否则,实现它的首选解决方法/最佳实践是什么?

...我们希望通过前端 Web 应用程序执行单个查询,而不使用后端 Web 应用程序来构建响应,因为该数据已经在 solr 中。

4

1 回答 1

0

我整理收藏的方式是错误的,我是这样做的:

<dataConfig>
  <dataSource type="JdbcDataSource"
            driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/circulo_lectores"
            user=""
            password="" /> 
  <document>
        <entity name="book" query="SELECT * FROM book">

            <field column="id" name="id"/>
            <field column="book" name="book" />

            <entity name="book_author" query="SELECT * FROM book_author WHERE book_id= ${book.id}">         
                <field column="author_id" name="author_id" />
                <entity name="author" query="select * FROM author WHERE id = ${book_author.author_id}">
                    <field column="author_name" name="author_name" />
                </entity>                   
            </entity>   

            <entity name="book_category" query="SELECT * FROM book_category WHERE book_id= ${book.id}">         
                <field column="category_id" name="category_id" />
                <entity name="category" query="select * FROM category WHERE id = ${book_category.category_id}">
                    <field column="category_name" name="category_name" />
                </entity>                   
            </entity>               

        </entity>   
  </document>
</dataConfig>

这个参考给了我线索。希望它可以帮助别人

于 2016-05-27T07:55:21.153 回答