太阳地理层次 [英] solr geography hierarchy

查看:81
本文介绍了太阳地理层次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找到一种在solr中实现具有层次结构的构面的方法,却无法弄清在我的情况下该如何做.我已经阅读了几篇有关在solr中执行层次结构的文章以及补丁64和792中的解决方案.我遇到的主要问题是我拥有可以属于该层次结构的多个分支的实体.我当前的数据形式是带有国家,州和城市MVA的用户文档.

I've been trying to figure out a way to implement faceting with hierarchies in solr and can't figure out how to do it in my situation. I've read a couple of the articles on doing hierarchies in solr along with the solutions in patch 64 and 792. The main issue I'm having is that I have entities that can belong to multiple branches of the hierarchy. The current form of my data is a user document with MVAs for country, state, and city.

以地理层次结构为例,人们可以列出其服务直至城市级别.一个人可以为整个阿拉巴马州服务,但只能为乔治亚州的某些城镇服务.现在,州一级的构面计数会计算为一个区域服务的不同个人,该地区在阿拉巴马州为1,在佐治亚州为1,当扩展到城市级别时,每个城市都有一个计数(换句话说,城市总数计数不一定等于状态计数,因为计数不是相互排斥的.

Take for instance a geographical hierarchy that people can list their services for down to a city level. A person may service all of alabama but only certain towns in georgia. Now the faceting count for the state level counts the distinct individuals that service an area which is a 1 for alabama and a 1 for georgia and when expanded down to the city level has a count for each city (in other words the sum of the city counts won't necessarily equal the state count since the counts are not mutually exclusive).

US(1)
乔治亚州(1)
亚特兰大(1)
哥伦布(0)
雅典(0)
阿拉巴马州(1)
移动设备(1)
伯明翰(1)
亨茨维尔(1)

US(1)
Georgia(1)
Atlanta(1)
Columbus(0)
Athens(0)
Alabama(1)
Mobile(1)
Birmingham(1)
Huntsville(1)

我要挂断的部分是面对城市时,由于用户在阿拉巴马州和佐治亚州都被列出,所以我无法知道它们属于哪个州,我也想不出一种联系方式彼此具有属性.如果solr-64对于同一文档支持多个分支(例如US/Alabama/Mobile/和US/Georgia/Atlanta/),则可能会起作用.截至目前,尽管如此,我仍无法使其与夜间版本一起进行编译,因此我有点被卡住了.

The part I'm getting hung up on is when faceting on the cities I have no way of knowing what state they belong to since the user is listed in both alabama and georgia and I can't figure out a way to relate attributes to each other. solr-64 might work if it supports multiple branches like US/Alabama/Mobile/ and US/Georgia/Atlanta/ for the same document. As of right now I havent been able to get it to compile with the nightly build though so I'm kind of stuck.

有人有更好的方法吗?

Does anyone have a better way of doing this?

推荐答案

请参阅描述的第一个用例

See the first use case described here. (client side processing for indexing and querying necessary!)

类别导航

问题:您有一棵类别树,并且您的产品被分类为多个类别.

The problem: you have a tree of categories and your products are categorized in multiple of those categories.

对于此问题,有两种相对类似的解决方案.我将描述其中之一:

There are two relative similar solutions for this problem. I will describe one of them:

  • 创建一个名为"category"的多值字符串字段.使用类别ID(或名称,如果要避免数据库查询).
  • 您有一个类别树.确保文档不仅获取叶类别,还获取直到根节点为止的所有类别.
  • 现在在类别字段上使用"-1"作为限制
  • 但是,如果您只想显示一个级别的类别怎么办?例如.如果您一次不想其他级别,或者它们太多了.

  • Create a multivalued string field called ‘category’. Use the category id (or name if you want to avoid DB queries).
  • You have a category tree. Make sure a document gets not only the leaf category, but all categories until the root node.
  • Now facet over the category field with ‘-1′ as limit
  • But what if you want to display only the categories of one level? E.g. if you don’t want other level at a time or if they are too much.

然后索引类别字段ala <level>_category.为此,在建立索引时,您将需要RAM中完整的类别树.然后使用facet.prefix=<level>_过滤级别的类别列表

Then index the category field ala <level>_category. For that you will need the complete category tree in RAM while indexing. Then use facet.prefix=<level>_ to filter the category list for the level

如果您过滤级别,则仍然有一个问题:

If you filter the level then one question remains:

问:如何显示从所选类别到根类别的路径?

Q: how can you display the path from the selected category until the root category?

A:可以通过DB来获取类别父级,如果将类别ID存储在Solr中而不是类别名称,则很容易. 或者从参数列表中获取父级,这有点复杂但可行.在这种情况下,您需要将类别名称存储在Solr中.

A: Either get the category parents via DB, which is easy if you store the category ids in Solr – not the category names. Or get the parents from the parameter list which is a bit more complicated but doable. In this case you’ll need to store the category names in Solr.

这篇关于太阳地理层次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆