简体   繁体   English

从索引OrientDB中选择时,按其他属性而不是键排序

[英]Order by other property instead of Key when selecting from index OrientDB

I am using Orient DB 2.1.16 . 我正在使用Orient DB 2.1.16 I have a vertex class in orientDB called person , I also created a property for person class called name . 我在orientDB中有一个名为person的顶点类,我还为person类创建了一个名为name的属性。 I added a full text index on that property called person.name .Upon searching on index I can only order by key, is there any other way to search on index INDEX:person.name but order by another property of property of person like age SELECT FROM INDEX:person.name WHERE KEY CONTAINSTEXT 'abc' ORDER BY KEY ASC works fine but SELECT FROM INDEX:person.name WHERE KEY CONTAINSTEXT 'abc' ORDER BY age ASC gives error saying when selecting from index can only order by key 我在名为person.name的属性上添加了全文索引。索引上搜索时,只能按键进行排序,还有其他方法可以对索引INDEX:person.name进行搜索,但可以通过诸如age等属性的另一个属性进行排序SELECT FROM INDEX:person.name WHERE KEY CONTAINSTEXT 'abc' ORDER BY KEY ASC可以正常工作,但SELECT FROM INDEX:person.name WHERE KEY CONTAINSTEXT 'abc' ORDER BY age ASC给出错误,指出从索引中选择时只能按键排序

The result of Selecting from an index will not contain unindexed properties. 索引中选择的结果将不包含未索引的属性。 If you want to order by a field which is not part of the index, you need to select the related field also. 如果要按不属于索引的字段排序,则还需要选择相关字段。

Eg: 例如:

SELECT name, age FROM (SELECT EXPAND(rid) FROM INDEX:person.name WHERE
KEY CONTAINSTEXT 'abc') ORDER BY age ASC

More simple solution is to query properties from original vertex with the ContainsText operator: 更简单的解决方案是使用ContainsText运算符从原始顶点查询属性:

SELECT name, age from person WHERE (name CONTAINSTEXT 'abc') ORDER BY age ASC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM