Search using Apache TinkerPop methods on strings

Using Apache TinkerPop predicates with DSE Search indexes

Apache TinkerPop predicates can be used with DSE Search indexes in DataStax Graph (DSG). Note that this kind of search on strings is case-sensitive, so using Pork or pork will find different results. The supported predicates are:

  • containing()

  • notContaining()

  • startingWith()

  • notStartingWith()

  • endingWith()

  • notEndingWith()

containing()

In a traversal query, use a string search to list all recipes that have the word Pork in the recipe name. A partial match of the recipe name returns a result, unlike eq(). Note that this search is case-sensitive, so using pork would not find a vertex.

g.V().has('recipe', 'name', containing('Pork')).values('name')

results in:

==>Roast Pork Loin

notContaining()

In a traversal query, use a string search to list all recipes that do not have the word Pork in the recipe name using notContaining(). A partial match of the recipe name will exclude the name from the result, unlike neq().

g.V().has('recipe', 'name', notContaining('Pork')).values('name')

results in:

==>Salade Nicoise
==>Wild Mushroom Stroganoff
==>Spicy Meatloaf
==>Oysters Rockefeller
==>Rataouille
==>Carrot Soup
==>Beef Bourguignon

startingWith()

In a traversal query, use a string search to find all recipes that have a name beginning with Beef. The method startingWith() is used with a supplied string.

g.V().has('recipe', 'name', startingWith('Beef')).values('name')

results in:

==>Beef Bourguignon

Matches are found for each recipe name that begins with Beef, provided the recipe name was designated with asString() in the search index. A search using startingWith('Bee') will find the same result; full words are not necessary.

prefix() and startingWith() will return the same results.

notStartingWith()

In a traversal query, use a string search to find all recipes that do not have a name beginning with Beef. The method notStartingWith() is used with a supplied string.

g.V().has('recipe', 'name', notStartingWith('Beef')).values('name')

results in:

==>Salade Nicoise
==>Wild Mushroom Stroganoff
==>Spicy Meatloaf
==>Oysters Rockefeller
==>Rataouille
==>Carrot Soup
==>Roast Pork Loin

endingWith()

In a traversal query, use a string search to find all recipes that have a name that ends with Soup. The method endingWith() is used with a supplied string. A search using endingWith('oup') will find the same result; full words are not necessary.

g.V().has('recipe', 'name', endingWith('Soup')).values('name')

results in:

==>Carrot Soup

notEndingWith()

In a traversal query, use a string search to find all recipes that do not have a name that ends with Soup. The method notEndingWith() is used with a supplied string.

g.V().has('recipe', 'name', notEndingWith('Soup')).values('name')

results in:

==>Salade Nicoise
==>Wild Mushroom Stroganoff
==>Spicy Meatloaf
==>Oysters Rockefeller
==>Rataouille
==>Beef Bourguignon
==>Roast Pork Loin

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com