开发者

Dealing with many calendars and good way to store / query them

Some model first : We have Ad that contain a Calendar. Each date has a boolean (more like a ternary valued field, but that does not change the problem) to check the disponibility of the Ad on that date (yes, no, unknown). I want to make a solr index to be able to search开发者_如何学JAVA Ad as Document (that part is done) and add some faceting or querying on disponibility.

ie: Ad matching ... plus disponible between A and B. then solr return me the list of Ad document that has their calendar with disponible (or unknown...) on those date.

How can I describe a Solr Index to be able to search Ads with such constraints, if it is posible?

Any help is greatly appreciated and thanks for your time. Sorry for my bad english and any grammar review would be nice!


Achieving search output in your desired form first requires proper schema structure. Based on your description, you have three fields: "ad", "date" and "disponibility". However, you want "date" and "disponibility" associated with each other. Structuring the index as separate fields isn't desirable.

In this case, consider the following schema:

<fields>
  <field name="ad" type="string" indexed="true" stored="true" required="true" />
  <field name="disp-yes" type="date" indexed="true" stored="true" required="true" multiValued="true"/>
  <field name="disp-no" type="date" indexed="true" stored="true" required="true" multiValued="true"/>
  <field name="disp-unknown" type="date" indexed="true" stored="true" required="true" multiValued="true"/>
</fields>

(Guesses made for indexed, stored and datatype attributes.)

In this schema, you can index each ad and add your date values to the "disp-*" field definitions. When querying, you can then structure searches to retrieve ads based on disponibility as well as applying facet queries.

An added benefit of structuring the disp-* fields as date types is range query support, which applies both to search results as well as facets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜