Skip to content

When specifying an index why the expression is used? #2145

Answered by mbdavid
frenyibeni asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @frenyibeni,

The ideia behind expressions (created in v5) is create a generic way to create index based in any document field, method call or any transformation you need to be indexed. But in SQL, you create SELECTs and engine will choose best index to use. To select the best index, index name are not used because are just "the name of index" and not "what data are indexed". Like this:

If you create an index like this

engine.EnsureIndex("mycollection", "Name", "UPPER($.Name)"

All index keys will contains only UPPER strings of Name field. If you try run a query like this:

SELECT $ FROM mycollection WHERE $.Name = 'JOHN'

Index (Name) will not be used. Only if you run

SELECT $ FROM mycoll…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mbdavid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants