Search code examples
orientdborientdb-2.1

OrientDB count phrase in field


How can I count a phrase instances in a field using OrientDB?

Let's say I have the following data:

Display_title | Description
My_data_12 | The quick brown fox jumps over the lazy dog
My_data_13 | The one

How can I count the number of 'the' instances, output similar to this:

Display_title | Count
My_data_12 | 2
My_data_13 | 1


Solution

  • using @Vitim.us answer from here

    screenshot

    you can call it from studio with

    select title, occurrences(@this.description, "the") from v
    

    NOTE that this is case sensitive, so with your example you'll get:

     title      | occurrences
     My_data_12 | 1
     My_data_13 | 0