Answers.Body: <p>I got it.</p>
  
  <pre><code>'criteria' =&gt; [ 'title' =&gt; '*'.Craft::$app-&gt;request-&gt;getParam("key").'*' ]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-12T12:06:40.290Z
Answers.LastActivityDate: 2018-12-12T12:06:40.290Z
Answers.UserDisplayName: Flying Car 0013
Body: <p>I am trying to retrieve search suggestions for a search form. I sent the parameter entered by the user, but how do I do it in the criteria?
  I tried this:</p>
  
  <pre><code>'criteria' =&gt; [
      'search' =&gt; 'title: *'.Craft::$app-&gt;request-&gt;getParam("key").'*'
  ],
  </code></pre>
  
  <p>but it does not return any results. What am I doing wrong?
  this is my entire endpoint:</p>
  
  <pre><code>'suggests' =&gt;function(){
          return [
              'elementType' =&gt; Product::class,
              'paginate' =&gt; false,
              'pretty' =&gt; true,
              'criteria' =&gt; [
                  'limit' =&gt; 15,
                  'search' =&gt; 'title: *'.Craft::$app-&gt;request-&gt;getParam("key").'*'
              ],
              'transformer' =&gt; function(Product $product)  {
                  return [
                      'title' =&gt; $product-&gt;title,
                      'url' =&gt; $product-&gt;url
                  ];
              },
          ];
      },
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-11T10:45:27.527Z
Comments.Text: Got it. LOL 
  'criteria' => [
                      'title' => '*'.Craft::$app->request->getParam("key").'*'
                  ],
  that was fast.
Comments.UserDisplayName: Flying Car 0013
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-12T05:05:21.143Z
Comments.Text: Glad you got it sorted! Would you mind adding that as an official answer in case it ends up helping someone in the future?
Comments.UserDisplayName: Brad Bell
Tags: <plugin-elementapi><plugin-craftcommerce2>
Title: Check if title field has a string in ElementAPI
ThreadText: # Check if title field has a string in ElementAPI
  
  (Asked by: username_0 on 2018-12-11)
  
  I am trying to retrieve search suggestions for a search form. I sent the parameter entered by the user, but how do I do it in the criteria?
  I tried this:
  
  ```
  'criteria' => [
      'search' => 'title: *'.Craft::$app->request->getParam("key").'*'
  ],
  
  ```
  
  but it does not return any results. What am I doing wrong?
  this is my entire endpoint:
  
  ```
  'suggests' =>function(){
          return [
              'elementType' => Product::class,
              'paginate' => false,
              'pretty' => true,
              'criteria' => [
                  'limit' => 15,
                  'search' => 'title: *'.Craft::$app->request->getParam("key").'*'
              ],
              'transformer' => function(Product $product)  {
                  return [
                      'title' => $product->title,
                      'url' => $product->url
                  ];
              },
          ];
      },
  
  ```
  
  **Tags:** plugin-elementapi, plugin-craftcommerce2
  
  > **Comments:**
  > **username_0**: Got it. LOL  'criteria' => [                     'title' => '*'.Craft::$app->request->getParam("key").'*'                 ], that was fast.  
  > **username_1**: Glad you got it sorted! Would you mind adding that as an official answer in case it ends up helping someone in the future?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-12-12. Score: 1
  
  I got it.
  
  ```
  'criteria' => [ 'title' => '*'.Craft::$app->request->getParam("key").'*' ]
  
  ```
  
  
  ---
  
  