NULL位置字段的查询

NULL位置字段的查询

本文介绍了Solr-如何构造需要NOT NULL位置字段的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Solr索引,其中一组坐标存储为Location类型;我想查询该字段具有非空值的文档.

I have a Solr index with a set of coordinates stored as a Location type; I would like to query for documents where this field has a non-null value.

对位置"字段执行NOT NULL检查的查询语法是什么?

What is the query syntax to perform the NOT NULL check on a Location field?

推荐答案

规范的方式是这样的:

fieldName:[* TO *]

按照Paige Cook的建议在左侧使用''也可能有效,但我对它的信任程度不如上面.而且由于这是针对位置字段的,因此您可能必须针对两个基础实际字段之一与此逻辑组合字段进行比较.它们以fieldName开头,并以某种数字后缀结尾.在模式浏览器"中查看实际名称是什么.

Using a '' on the left side as Paige Cook suggested will probably work too but I don't trust it as much as I do the above. And since this is to a Location field, you will probably have to do this against one of the two underlying actual fields versus this logical composite field. They start with fieldName and end with some sort of numeric suffix; look in the Schema Browser to see what the actual name is.

这里要注意的重要一点是,对于Solr来说,执行这样的查询非常昂贵,因为它需要对该字段执行全索引扫描.如果您有许多不同的位置字段值(成千上万?),那么这很重要.如果在过滤器查询中执行此操作,则将其缓存并且可能没有意义.如果希望此查询快速运行,那么在索引时,应索引一个布尔值字段以指示此字段中是否有值.

An important thing to be aware of here is that a query like this is expensive for Solr to do as it much do a full index scan on this field. If you have many distinct location field values (thousands on up?), then this is a big deal. If you do this in a filter query, then it will be cached and it's perhaps moot. If you want this query to run fast, then at index time you should index a boolean field to indicate if there is a value in this field or not.

这篇关于Solr-如何构造需要NOT NULL位置字段的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:20