Augie
Augie

Reputation: 1341

parse.com containsAllObjectsInArray limit

I am running into a limit during a pfquery using containsAllObjectsInArray.

My objects in parse have an array attribute that can contain up to 12 strings, the query works great as long as my search query array is 9 or less strings.

When I do a PFQuery on this table using containsAllObjectsInArray and my search array contains anything more than 9 objects, I get the following error.

Error: Too many terms in $all query (Code: 154, Version: 1.2.19)

So obviously the containsAllObjectsInArray can only search 9 or less matches within an array.

Is this going to be fixed?

I was following Parse's example blog post on scalable searches using tags, http://blog.parse.com/2013/03/19/implementing-scalable-search-on-a-nosql-backend/. very surprised this is the method recommended and it bombs after object has more than 9 tags.

Upvotes: 2

Views: 377

Answers (2)

Jose A. Gallardo
Jose A. Gallardo

Reputation: 11

I apply the same solution, I splitted the query with maximum 9 items and works. Here is a sample code for PHP:

    $totalTags = count($tags);
    $theQuery = new ParseQuery("articles");
    if($totalTags  > 9){
        $c=0;
        for($i=0;$i<($totalTags/9);$i++){
            $limitArray = Array();
            $h = 0;
            $ini = $c;
            $fin = min(9+$c,$totalTags);
            for($j = $ini; $j < $fin; $j++){
                $limitArray[$h] = $tags[$j];
                $c++;
                $h++;
            }
            $theQuery->containsAll("tags", $limitArray);
        }
    }else{
        $theQuery->containsAll("tags", $tags);  
    }
    $articles = $theQuery->find();

Upvotes: 1

Augie
Augie

Reputation: 1341

I should of tried this first before posting, but I simply split my search into sub arrays all with max size of 9 and then added them each to the pfquery in multiple containsAllObjectsInArray calls. Query worked fine. Kind of a hack work around, but works for now.

Upvotes: 1

Related Questions