gpt4 book ai didi

zend-framework - Zend 搜索 lucene

转载 作者:行者123 更新时间:2023-12-01 04:22:00 25 4
gpt4 key购买 nike

我有一个数据库,我想与 Zend_Search_Lucene 一起使用.但是,我很难为 Lucene 创建一个“完全可搜索”的文档。

每个Zend_Search_Lucene文档从两个关系数据库表( Table_OneTable_Two )中提取信息。 Table_One有基本信息( idowner_idtitledescriptionlocation 等)、Table_TwoTable_One 有 1:N 的关系(意思是,对于 Table_One 中的每个条目, Table_Two 中可能有一个或多个条目)。 Table_Two 包含:id,listing_id , bedrooms , bathrooms , price_min , price_max , date_available .参见图 1。

图1

Table_One
id (Primary Key)
owner_id
title
description
location
etc...

Table_Two
id (Primary Key)
listing_id (Foreign Key to Table_One)
bedrooms (int)
bathrooms (int)
price_min (int)
price_max (int)
date_available (datetime)

问题是,有多个 Table_Two每个条目 Table_One入口。 【问题1】如何创建 Zend_Search_Lucene每个字段都是唯一的文档? (见图2)

图2
Lucene Document
id:Keyword
owner_id:Keyword
title:UnStored
description:UnStored
location: UnStored
date_registered:Keyword
... (other Table_One information)
bedrooms: UnStored
bathrooms: UnStored
price_min: UnStored
price_max: UnStored
date_available: Keyword
bedrooms_1: <- Would prefer not to have do this as this makes the bedrooms harder to search.

接下来,我需要能够对 bedrooms 进行范围查询, bathrooms , price_minprice_max领域。 (例如:查找包含 1 到 3 间卧室的文档) Zend_Search_Lucene将只允许在同一字段上进行范围搜索。根据我的理解,这意味着我想要进行范围查询的每个字段只能包含一个值(例如:卧室:“1 卧室”);

我现在在 Lucene 文档中拥有的是 bedrooms , bathrooms , price_min , price_max , date_available以空格分隔的字段。

例子:
Sample Table_One Entry: 
| 5 | 2 | "Sample Title" | "Sample Description" | "Sample Location" | 2008-01-12

Sample Table_Two Entries:
| 10 | 5 | 3 | 1 | 900 | 1000 | 2009-10-01
| 11 | 5 | 2 | 1 | 800 | 850 | 2009-08-11
| 12 | 5 | 1 | 1 | 650 | 650 | 2009-09-15

示例 Lucene 文档
id:5
owner_id:2
title: "Sample Title"
description: "Sample Description"
location: "Sample Location"
date_registered: [datetime stamp YYYY-MM-DD]
bedrooms: "3 bedroom 2 bedroom 1 bedroom"
bathrooms: "1 bathroom 1 bathroom 1 bathroom"
price_min: "900 800 650"
price_max: "1000 850 650"
date_available: "2009-10-01 2009-08-11 2009-09-15"

[问题 2] 你能在 bedroom 上做范围查询搜索吗? , bathroom , price_min , price_max , date_available上面显示的字段还是每个范围查询字段必须只包含一个值(例如“1 间卧室”)?我无法让范围查询以其当前形式工作。我在这里不知所措。

提前致谢。

最佳答案

  • 我建议您为 Table_Two 中的每个条目创建一个单独的 Lucene 文档。这将导致这些条目共有的 Table_One 信息的一些重复,但这对于 Lucene 中更简单的索引结构来说并不是一个高昂的代价。
  • 使用 boolean query合并几个range queries .数值字段应该是这样的:
  • bedrooms: 3 price_min: 900
    使用 Lucene 语法的示例查询将是:
    date_available:[20100101 TO 20100301] AND price_min:[600 TO 1000]

    关于zend-framework - Zend 搜索 lucene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1053039/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com