Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Select and sort nodes using scripture reference #1

Open
rudolfbyker opened this issue Dec 30, 2015 · 0 comments
Open

Select and sort nodes using scripture reference #1

rudolfbyker opened this issue Dec 30, 2015 · 0 comments

Comments

@rudolfbyker
Copy link
Member

We need a robust way to select all nodes that reference all or part of a given verse range. Additionally, they need to be sorted by the quality of the match.

Problems with selecting nodes

  • There can be arbitrarily many fields of type "Scripture Reference", each having a user-specified name. Which fields are used in the EntityFieldQuery when trying to select nodes?
    • We could maintain an index table, like taxonomy_index (see the taxonomy module). This is fast and reliable, but the table will be huge (number of records is the number of verses times the number of nodes, assuming each node has only one value in the Scripture Reference field).
    • We could provide this functionality for a single field instance only, but this severely limits the versatility of the module.

Problems with sorting nodes

  • There are multiple ways to determine the quality of a match between a query range and the range stored in a field on an entity:
    • Query match quality := the percentage of the query range that is covered by the entity's range
      • If the user is looking for Psalm 8:2, top results will include entities referencing the whole of Psalms 1-150, since it covers 100% of the query range.
      • If the user is looking for Psalms in general, any entity that references a single Psalm will be ranked very low (especially for short Psalms).
    • Entity match quality := the percentage of the entity's range that is covered by the query range
      • If the user is looking for Psalm 8:2, entities referencing the whole of Psalms 1-150 will be ranked low, because it only covers one verse in the book.
      • If the user is looking for Psalms is general, all entities that reference a single verse from Psalms will be ranked at the very top, since the query covers 100% of the entity's range.
  • Calculating the number of actual verses between to vids (verse ids) is difficult. We cannot sort verses by versenum any more, nor do arithmetic using versenums, since it has been changed to a varchar, causing verses to be sorted like 1, 10, 11, 12, 13, ... Now we sort by vid (verse id). This is OK (and even faster), because @krokkie made sure that the vids are ordered canonically for all bible translations by allowing ample space between vids for verses to be added later if necessary. This means that the versenum is actually the name of the verse, just like we have book names. For now, we subtract two vids from one another to estimate the number of verses between them, but this is a very crude solution. It also breaks when trying to estimate how many verses are between two chapters of a book, since the gaps between verse ids there are (for some translations) bigger than normal.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants