简体   繁体   中英

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

I am using Orient DB 2.1.16 . I have a vertex class in orientDB called person , I also created a property for person class called 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

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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