2.0RC1, containstext issue

38 views
Skip to first unread message

Erik Peterson

unread,
Jan 6, 2015, 10:54:52 PM1/6/15
to orient-...@googlegroups.com
I have a simple class geo with location property with string items like 
"united states"
"houston, texas, united states"
...

select geo where location containstext "united"
Returns records as expected

However...

select geo where location containstext "united "
select geo where location containstext "united s"
select geo where location containstext "united states"
etc.
Does not return records as expected. No records are returned. 

Why?

Same behavior with and without index.



Erik Peterson

unread,
Jan 6, 2015, 11:12:09 PM1/6/15
to orient-...@googlegroups.com
Correction. Works without fulltext index. Fails with fulltext index.

Luigi Dell'Aquila

unread,
Jan 7, 2015, 2:31:01 AM1/7/15
to orient-...@googlegroups.com
Hi Erik,

fulltext index is a very basic implementation of a full text search (probably it will be discontinued in next releases), it just splits sentences in words based on blank spaces and then performs search on single words, so if you use more than a word in a "containstext" constraint, it will not return any results.
I suggest you to use a Lucene index to have better indexing, more flexibility and much better performance


Luigi


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

coach3pete

unread,
Jan 7, 2015, 3:17:37 AM1/7/15
to orient-...@googlegroups.com
Thanks Luigi,
Just started using it since the post. Faster and more powerful...but still trying to understand the search behavior. Thanks again.

You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/yroAgjsFpaI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

Riccardo Tasso

unread,
Jan 7, 2015, 3:44:22 AM1/7/15
to orient-...@googlegroups.com
Hi,
  assume you have the following record:
#1:1, "houston, texas, united states"

If there is no index the semantics of CONTAINSTEXT will iterate over all the records returning only those wich contains the substring, hence:
SELECT FROM V WHERE txt CONTAINSTEXT "united s"
will return: #1:1

If there is a FULLTEXT index it will contain something like:
"houston", #1:1
"texas", #1:1
"united", #1:1
"states", #1:1

In this case when you use the CONTAINSTEXT operator, orientdb will search the existence of your query string as a key over the FULLTEXT index, hence:

SELECT FROM V WHERE txt CONTAINSTEXT "united s"
will return: NOTHING (since in the index there isn't any key equals to "united s")

SELECT FROM V WHERE txt CONTAINSTEXT "united"
will return: #1:1

If you have a FULLTEXT index you can always search a substring, with LIKE operator:
SELECT FROM V WHERE txt like "%united s%"
will return: #1:1
But remember than in this case you wouldn't benefit of the index.

Cheers,
   Riccardo



Reply all
Reply to author
Forward
0 new messages