title: Spring data elasticsearch query products with multiple fields
body: <p>ES newbie here, sorry for the dumb question.</p>
  
  <p>I have been trying to create a elasticsearch query for a <code>products</code> index. I'm able to query it, but it never returns as I expect.</p>
  
  <p>I'm probably using the query builder in a wrong way, have tried all sorts of queries builders and never got to make it work as I expected.</p>
  
  <p>My <strong>Product</strong> class (simpler for the sake of the question):</p>
  
  <pre><code>public class Product {
  
      private String sku;
  
      private Boolean soldOut;
  
      private Boolean freeShipping;
  
      private Store store;
  
      private Category category;
  
      private Set&lt;ProductUrl&gt; urls;
  
      private Set&lt;ProductName&gt; names;
  
  }
  </code></pre>
  
  <p><strong>Category</strong> nas <code>name</code> and <code>id</code> which I use for aggregations</p>
  
  <p>The boolean field are used for filters.</p>
  
  <p><strong>ProductName</strong> and <strong>ProductUrl</strong> both have a <code>String locale</code> and <code>String name</code> or <code>String url</code> accordingly</p>
  
  <p>I am currently building my query with the following logic</p>
  
  <pre><code>private SearchQuery buildSearchQuery(String searchTerm, List&lt;Long&gt; categories, Pageable pageable) {
      NativeSearchQueryBuilder builder = new NativeSearchQueryBuilder();
      if (searchTerm != null) {
          builder.withQuery(
                  new MultiMatchQueryBuilder(searchTerm, "names.name", "urls.url", "descriptions.description", "sku")
                          .operator(Operator.AND)
                          .type(MultiMatchQueryBuilder.Type.MOST_FIELDS)
          );
      }
      builder.withPageable(pageable);
      return builder.build();
  }
  </code></pre>
  
  <p>The problem is that lots of products are not being matched, for example:</p>
  
  <p>query "andro" does not return "android" products.</p>
  
  <p>What am I missing? Is this way of building the query right?</p>
  
  <p><strong>UPDATE</strong>
  Adding the <code>names</code> part of my product mapping:</p>
  
  <pre><code>    {
      "mappings": {
          "product": {
              "properties": {
                  "names": {
                      "properties": {
                          "id": {
                              "type": "long"
                          },
                          "name": {
                              "type": "string"
                          },
                          "locale": {
                              "type": "string"
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>