You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Mohit Kataria (Jira)" <ji...@apache.org> on 2021/06/11 07:04:00 UTC

[jira] [Commented] (OAK-9457) Lucene index is always used over ES index when the cost is minimal

    [ https://issues.apache.org/jira/browse/OAK-9457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17361466#comment-17361466 ] 

Mohit Kataria commented on OAK-9457:
------------------------------------

There is minimum cost assigned to different type of indexes:
||Index Type||min cost||
|reference index|1.0|
|property index|2.0|
|nodetype|2.05|
|luceneproperty index|2.1|
|elastic index:|2.2|
|Lucene Aggregate Index|2.2|
|Solr Aggegate Index|2.3|

In case the "best cost" from previous evaluation of any of the indexes is less than this min cost we stop further evaluation[1].

Suggestions is a special case (native query is used) and for this we use defaultPlan [2].

But here also for native queries we override estimatedEntryCount() with value 1 [3].

(For suggestions we don't use number of documents in index to estimate cost.)

Now once we have plan, cost is evaluated as [4] which is
{code:java}
double c = p.getCostPerExecution() + entryCount * p.getCostPerEntry(); {code}
which is equivalent to 1.0 + 1.0 * 1.0 i.e 2.0 for lucene's  cost for suggestions.

Now as min cost of elastic index is 2.2 which is greater than 2.0 of lucene suggestions, no further evaluation happens even though for elastic final cost is 1.9 even if we decreased costPerExecution or costPerEntry for elatic index.
Here if we increase costPerExecution for damAssetLucene so that it is just above 2.2, will solve this for us.

  
Note: the same scenario will also be valid for spellcheck as spellcheck also uses native query [5].

[1]: [https://github.com/oak-indexing/jackrabbit-oak/blob/53eaf3c849ef62adb719602d9876af35b1588ed5/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java#L1043]

[2]: [https://github.com/oak-indexing/jackrabbit-oak/blob/53eaf3c849ef62adb719602d9876af35b1588ed5/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndexPlanner.java#L743]

[3]: [https://github.com/oak-indexing/jackrabbit-oak/blob/53eaf3c849ef62adb719602d9876af35b1588ed5/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndexPlanner.java#L444]

[4]: [https://github.com/oak-indexing/jackrabbit-oak/blob/53eaf3c849ef62adb719602d9876af35b1588ed5/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java#L1077]

[5]: [https://github.com/oak-indexing/jackrabbit-oak/blob/53eaf3c849ef62adb719602d9876af35b1588ed5/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndexPlanner.java#L426]

> Lucene index is always used over ES index when the cost is minimal
> ------------------------------------------------------------------
>
>                 Key: OAK-9457
>                 URL: https://issues.apache.org/jira/browse/OAK-9457
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: indexing
>    Affects Versions: 1.40.0
>            Reporter: Mohit Kataria
>            Assignee: Mohit Kataria
>            Priority: Major
>
> In case of suggestions and spellcheck i.e. native queries. The cost evaluation for using index comes out to be 2.0 which is smaller than even minimum cost of the indexes.
> This leads to non-evaluation of further index types. In this case elastic.
>  
> Minimum cost for indexes are as follows:
> ||Index Type||min cost||
> |reference index|1.0|
> |property index|2.0|
> |nodetype|2.05|
> |luceneproperty index|2.1|
> |elastic index:|2.2|
> |Lucene Aggregate Index|2.2|
> |Solr Aggegate Index|2.3|
>  
> Formulation for cost evaluation is :
> double c = p.getCostPerExecution() + entryCount * p.getCostPerEntry(); 
> Which for native queries is equivalent to 1.0 + 1.0 * 1.0 i.e 2.0.
> So make sure that index evaluation is not stopped at lucene indexes we are going to change EstimatedEntryCount to 2 from 1 which will return cost for suggestions and spellcheck as 3.0
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)