Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework zend搜索lucene_Zend Framework_Search_Lucene_Document - Fatal编程技术网

Zend framework zend搜索lucene

Zend framework zend搜索lucene,zend-framework,search,lucene,document,Zend Framework,Search,Lucene,Document,我有一个数据库,我想利用Zend\u Search\u Lucene。然而,我很难为Lucene创建一个“完全可搜索”的文档 每个Zend\u Search\u Lucene文档都从两个关系数据库表中提取信息(Table\u One和Table\u two)表1有基本信息(id,owner\u id,title,description,location,等等),表2与表1有1:N关系(意思是说,对于表1中的每个条目,表2中可能有一个或多个条目)。表二包括:id、列表id、卧室、浴室、最低价格、最

我有一个数据库,我想利用
Zend\u Search\u Lucene
。然而,我很难为Lucene创建一个“完全可搜索”的文档

每个
Zend\u Search\u Lucene
文档都从两个关系数据库表中提取信息(
Table\u One
Table\u two
)<代码>表1有基本信息(
id
owner\u id
title
description
location
,等等),
表2
表1
有1:N关系(意思是说,对于
表1
中的每个条目,
表2
中可能有一个或多个条目)。表二包括:id、
列表id
卧室
浴室
最低价格
最高价格
可用日期
。参见图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\u One
条目都有多个
Table\u Two
条目。[问题1]如何创建每个字段都是唯一的
Zend\u Search\u 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.
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]您是否可以在上面显示的
卧室
浴室
价格最低
价格最高
日期可用
字段上进行范围查询搜索,还是每个范围查询字段必须只包含一个值(例如“1个卧室”)?我无法使范围查询以其当前形式工作。我在这里不知所措

提前谢谢

  • 我建议您为表2中的每个条目创建一个单独的Lucene文档。这将导致这些条目所共有的表信息的某些重复,但这并不是为Lucene中更简单的索引结构付出的高昂代价
  • 使用a组合多个。数值字段应如下所示:
  • 卧室:3间

    price\u min:900

    Lucene语法中的示例查询如下:

    date_available:[20100101 TO 20100301] AND price_min:[600 TO 1000]
    

    谢谢这正是我所做的,而且效果很好。谢谢你。
    date_available:[20100101 TO 20100301] AND price_min:[600 TO 1000]