FgForrest / evitaDB

evitaDB is a specialized database with an easy-to-use API for e-commerce systems. It is a low-latency NoSQL in-memory engine that handles all the complex tasks that e-commerce systems have to deal with on a daily basis. evitaDB is expected to act as a fast secondary lookup/search index used by front stores.
https://evitadb.io
Other
62 stars 7 forks source link

Cannot order by reference attribute when not manually fetched #647

Closed lukashornych closed 2 months ago

lukashornych commented 3 months ago

When defining order by with attribute natural ordering on reference content without actually requesting the attribute, evitaDB throws error stating that the attribute must be requested:

Error:

Attribute `orderInCategory` was not fetched along with the entity. You need to use `attributeContent` requirement in `referenceContent` of your `require` part of the query.

Example query

query listProduct {
    listProduct {
      primaryKey
      categories( orderBy:{ attributeOrderInCategoryNatural: DESC}) {
        referencedEntity {
          primaryKey
        }
      }
    }
  }

I suppose the problem is that this sorting is done by the EntityDecorator instead of the engine itself, hence the required attribute. However, I would expect that the evitaDB server would visit the entire query prior to fetching the entites and request such needed attributes by it self.

novoj commented 2 months ago

Fixed in #260 branch.