<p>Simple one really.  In SQL, if I want to search a text field for a couple of characters, I can do:</p>

<pre><code>SELECT blah FROM blah WHERE blah LIKE '%text%'
</code></pre>

<p>The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?</p>

[{'answer_id': 47811, 'author': 'David Webb', 'author_id': 3171, 'author_profile': 'https://Stackoverflow.com/users/3171', 'pm_score': 7, 'selected': True, 'text': '<p>BigTable, which is the database back end for App Engine, will scale to millions of records. Due to this, App Engine will not allow you to do any query that will result in a table scan, as performance would be dreadful for a well populated table.</p>\n\n<p>In other words, every query must use an index. This is why you can only do <code>=</code>, <code>&gt;</code> and <code>&lt;</code> queries. (In fact you can also do <code>!=</code> but the API does this using a a combination of <code>&gt;</code> and <code>&lt;</code> queries.)  This is also why the development environment monitors all the queries you do and automatically adds any missing indexes to your <code>index.yaml</code> file.</p>\n\n<p>There is no way to index for a <code>LIKE</code> query so it\'s simply not available.</p>\n\n<p>Have a watch of <a href="http://sites.google.com/site/io/under-the-covers-of-the-google-app-engine-datastore" rel="noreferrer">this Google IO session</a> for a much better and more detailed explanation of this.</p>\n'}, {'answer_id': 1096744, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 6, 'selected': False, 'text': '<p>i\'m facing the same problem, but i found something on google app engine pages:</p>\n\n<p>Tip: Query filters do not have an explicit way to match just part of a string value, but you can fake a prefix match using inequality filters:</p>\n\n<pre><code>db.GqlQuery("SELECT * FROM MyModel WHERE prop &gt;= :1 AND prop &lt; :2",\n            "abc",\n            u"abc" + u"\\ufffd")\n</code></pre>\n\n<p>This matches every MyModel entity with a string property prop that begins with the characters abc. The unicode string u"\\ufffd" represents the largest possible Unicode character. When the property values are sorted in an index, the values that fall in this range are all of the values that begin with the given prefix.</p>\n\n<p><a href="http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html" rel="noreferrer">http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html</a></p>\n\n<p>maybe this could do the trick ;)</p>\n'}, {'answer_id': 2136253, 'author': 'jbochi', 'author_id': 230636, 'author_profile': 'https://Stackoverflow.com/users/230636', 'pm_score': 4, 'selected': False, 'text': '<p>Altough App Engine does not support LIKE queries, have a look at the properties <a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty" rel="noreferrer">ListProperty</a> and <a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#StringListProperty" rel="noreferrer">StringListProperty</a>. When an equality test is done on these properties, the test will actually be applied on all list members, e.g., <code>list_property = value</code> tests if the value appears anywhere in the list.</p>\n\n<p>Sometimes this feature might be used as a workaround to the lack of LIKE queries. For instance, it makes it possible to do <a href="http://www.billkatz.com/2009/6/Simple-Full-Text-Search-for-App-Engine" rel="noreferrer">simple text search, as described on this post</a>.</p>\n'}, {'answer_id': 6204951, 'author': 'fernandohur', 'author_id': 718333, 'author_profile': 'https://Stackoverflow.com/users/718333', 'pm_score': 2, 'selected': False, 'text': '<p>Have a look at Objectify <a href="http://code.google.com/p/objectify-appengine/wiki/FrequentlyAskedQuestions#How_do_I_do_a_like_query_%28LIKE_%22foo%%22%29" rel="nofollow">here</a> , it is like a Datastore access API. There is a FAQ with this question specifically, here is the answer</p>\n\n<blockquote>\n  <p>How do I do a like query (LIKE "foo%")<br>\n  You can do something like a startWith, or endWith if you reverse the order when stored and searched. You do a range query with the starting value you want, and a value just above the one you want.</p>\n</blockquote>\n\n<pre><code>String start = "foo";\n    ... = ofy.query(MyEntity.class).filter("field &gt;=", start).filter("field &lt;", start + "\\uFFFD");\n</code></pre>\n'}, {'answer_id': 7529428, 'author': 'topchef', 'author_id': 59470, 'author_profile': 'https://Stackoverflow.com/users/59470', 'pm_score': 0, 'selected': False, 'text': '<p>If the <code>LIKE \'%text%\'</code> always compares to a word or a few (think permutations) and your data changes slowly (slowly means that it\'s not prohibitively expensive - both price-wise and performance-wise - to create and updates indexes) then Relation Index Entity (RIE) may be the answer. </p>\n\n<p>Yes, you will have to build additional datastore entity and populate it appropriately. Yes, there are some constraints that you will have to play around (one is 5000 limit on the length of list property in GAE datastore). But the resulting searches are lightning fast. </p>\n\n<p>For details see my <a href="http://novyden.blogspot.com/2011/02/efficient-keyword-search-with-relation.html" rel="nofollow">RIE with Java and Ojbectify</a> and <a href="http://novyden.blogspot.com/2011/09/efficient-keyword-search-with-relation.html" rel="nofollow">RIE with Python</a> posts. </p>\n'}, {'answer_id': 8281498, 'author': 'amit kumar', 'author_id': 19501, 'author_profile': 'https://Stackoverflow.com/users/19501', 'pm_score': 0, 'selected': False, 'text': '<p>"Like" is often uses as a poor-man\'s substitute for text search. For text search, it is possible to use <a href="https://github.com/tallstreet/Whoosh-AppEngine" rel="nofollow">Whoosh-AppEngine</a>. </p>\n'}, {'answer_id': 11112100, 'author': 'gzerone', 'author_id': 1070813, 'author_profile': 'https://Stackoverflow.com/users/1070813', 'pm_score': 1, 'selected': False, 'text': '<p>Just follow here:\ninit.py#354">http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/ext/search/<strong>init</strong>.py#354</p>\n\n<p>It works!</p>\n\n<pre><code>class Article(search.SearchableModel):\n    text = db.TextProperty()\n    ...\n\n  article = Article(text=...)\n  article.save()\n\nTo search the full text index, use the SearchableModel.all() method to get an\ninstance of SearchableModel.Query, which subclasses db.Query. Use its search()\nmethod to provide a search query, in addition to any other filters or sort\norders, e.g.:\n\n  query = article.all().search(\'a search query\').filter(...).order(...)\n</code></pre>\n'}, {'answer_id': 12697316, 'author': 'ryan', 'author_id': 186123, 'author_profile': 'https://Stackoverflow.com/users/186123', 'pm_score': 2, 'selected': False, 'text': '<p>App engine launched a general-purpose <a href="https://developers.google.com/appengine/docs/python/search/overview" rel="nofollow">full text search service</a> in version 1.7.0 that supports the datastore. </p>\n\n<p>Details in the <a href="http://googleappengine.blogspot.com/2012/05/looking-for-search-find-it-on-google.html" rel="nofollow">announcement</a>.</p>\n\n<p>More information on how to use this: <a href="https://cloud.google.com/appengine/training/fts_intro/lesson2" rel="nofollow">https://cloud.google.com/appengine/training/fts_intro/lesson2</a></p>\n'}, {'answer_id': 20204585, 'author': 'musketyr', 'author_id': 227419, 'author_profile': 'https://Stackoverflow.com/users/227419', 'pm_score': 3, 'selected': False, 'text': '<p>You need to use <a href="https://developers.google.com/appengine/docs/java/search/">search service</a> to perform full text search queries similar to SQL <code>LIKE</code>.</p>\n\n<p><a href="http://gaelyk.appspot.com/">Gaelyk</a> provides domain specific language to perform more <a href="http://gaelyk.appspot.com/tutorial/app-engine-shortcuts#advanced_fulltext_search">user friendly search queries</a>. For example following snippet will find first ten books sorted from the latest ones with title containing <code>fern</code>\nand the genre exactly matching <code>thriller</code>:</p>\n\n<pre><code>def documents = search.search {\n    select all from books\n    sort desc by published, SearchApiLimits.MINIMUM_DATE_VALUE\n    where title =~ \'fern\'\n    and genre =  \'thriller\'\n    limit 10\n}\n</code></pre>\n\n<p>Like is written as Groovy\'s match operator <code>=~</code>.\nIt supports functions such as <code>distance(geopoint(lat, lon), location)</code> as well.</p>\n'}, {'answer_id': 24414573, 'author': 'Edy Aguirre', 'author_id': 1617646, 'author_profile': 'https://Stackoverflow.com/users/1617646', 'pm_score': 1, 'selected': False, 'text': '<p>I tested this with GAE Datastore low-level Java API. Me and works perfectly</p>\n\n<pre><code>    Query q = new Query(Directorio.class.getSimpleName());\n\n    Filter filterNombreGreater = new FilterPredicate("nombre", FilterOperator.GREATER_THAN_OR_EQUAL, query);\n    Filter filterNombreLess = new FilterPredicate("nombre", FilterOperator.LESS_THAN, query+"\\uFFFD");\n    Filter filterNombre =  CompositeFilterOperator.and(filterNombreGreater, filterNombreLess);\n\n    q.setFilter(filter);\n</code></pre>\n'}, {'answer_id': 29152005, 'author': 'chuycepeda', 'author_id': 2178032, 'author_profile': 'https://Stackoverflow.com/users/2178032', 'pm_score': 1, 'selected': False, 'text': "<p>In general, even though this is an old post, a way to produce a 'LIKE' or 'ILIKE' is to gather all results from a '>=' query, then loop results in python (or Java) for elements containing what you're looking for.</p>\n\n<p>Let's say you want to filter users given a q='luigi'</p>\n\n<pre><code>users = []\nqry = self.user_model.query(ndb.OR(self.user_model.name &gt;= q.lower(),self.user_model.email &gt;= q.lower(),self.user_model.username &gt;= q.lower()))\n\nfor _qry in qry:\n if q.lower() in _qry.name.lower() or q.lower() in _qry.email.lower() or q.lower() in _qry.username.lower():\n      users.append(_qry)\n</code></pre>\n"}, {'answer_id': 38926030, 'author': 'Jose Salas', 'author_id': 3878671, 'author_profile': 'https://Stackoverflow.com/users/3878671', 'pm_score': 1, 'selected': False, 'text': '<p>It is not possible to do a LIKE search on datastore app engine, how ever creating an Arraylist would do the trick if you need to search a word in a string. </p>\n\n<pre><code>@Index\n    public ArrayList&lt;String&gt; searchName;\n</code></pre>\n\n<p>and then to search in the index using objectify.</p>\n\n<pre><code>List&lt;Profiles&gt; list1 = ofy().load().type(Profiles.class).filter("searchName =",search).list();\n</code></pre>\n\n<p>and this will give you a list with all the items that contain the world you did on the search</p>\n'}]
['https://Stackoverflow.com/questions/47786', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/366/']