1

我有一组标签多次出现的 xml 文档。例如<Address>以下文档中的标签。换句话说,父标签地址出现了 2 次。

我想搜索Name=ABCDZipCode=33333希望 solr 返回类似于下面给出的“响应文档”的响应。是否可以在 solr4.0 中执行此操作而不将 Address 定义为一个多值单字段,所有子字段都由分隔符分隔?

文档

<doc>
      <Name>ABCD</Name>
      <CompanyName>1234</CompanyName>
      <Address>
          <AddressLine1> 1725 ABCD Drive </AddressLine1>
          <AddressLine2> </Address Line2>
          <City>Miami</City>
          <State>FL</State>
          <Zipcode>33333</Zipcode>
          <AddressType>Home</AddressType>
      </Address>
      <Address>
          <AddressLine1> 16551 business blvd </AddressLine1>
          <AddressLine2> </Address Line2>
          <City>Miami</City>
          <State>FL</State>
          <Zipcode>33333</Zipcode>
          <AddressType>Business</AddressType>
      </Address>
</doc>
<doc>
      <Name>XYZWR</Name>
      <CompanyName>1234</CompanyName>
      <Address>
          <AddressLine1> 1725 ABCD Drive </AddressLine1>
          <AddressLine2> </Address Line2>
          <City>Miami</City>
          <State>FL</State>
          <Zipcode>33333</Zipcode>
          <AddressType>Home</AddressType>
      </Address>
      <Address>
          <AddressLine1> 16551 business blvd </AddressLine1>
          <AddressLine2> </Address Line2>
          <City>Phoenix</City>
          <State>AZ</State>
          <Zipcode>33333</Zipcode>
          <AddressType>Business</AddressType>
      </Address>
</doc>

响应文件

   <doc>
          <Name>ABCD</Name>
          <CompanyName>1234</CompanyName>
          <Address>
              <AddressLine1> 1725 ABCD Drive </AddressLine1>
              <AddressLine2> </Address Line2>
              <City>Miami</City>
              <State>FL</State>
              <Zipcode>33333</Zipcode>
              <AddressType>Home</AddressType>
          </Address>
          <Address>
              <AddressLine1> 16551 business blvd </AddressLine1>
              <AddressLine2> </Address Line2>
              <City>Miami</City>
              <State>FL</State>
              <Zipcode>33333</Zipcode>
              <AddressType>Business</AddressType>
          </Address>
    </doc>

问候

4

1 回答 1

0

我们必须存储去规范化。没有其他办法了。所以,我们存储像这样的字段

home_addressline1
home_zipcode
etc.,

来搜索,你可以有动态字段 - 2种动态字段,然后有一个复制字段,可以适当地复制到这些动态字段中

address_*
*_home (and/or) *_business etc.,

当用户想要搜索邮政编码并且不关心地址的“类型”时,您使用 address_* ,而当用户只想搜索“家庭类型”时,您使用 *_home 并且请求开始涌入仅搜索很快就会有某种地址类型:)

于 2013-08-09T17:22:10.200 回答