title: Implementing search : Identifying known keywords
body: <p>I have implemented search functionality for my e-Commerce website using elastic search. The basic structure is like, each product has a title and whatever the user enters I search the exact string using elastic and return the result.</p>
  
  <p>Now I notice that most of the search phrases (almost 90%) follow a similar pattern. It contains:</p>
  
  <ol>
  <li>Brand name of the product (Apple, Nokia etc.)</li>
  <li>Category of the product (phone, mobile phone, smartphone etc.)</li>
  <li>Model name of the product (iPhone 6S, Lumia 950 etc.)</li>
  </ol>
  
  <p>Now I think if I am able to identify the specific components, then I can return better results than just text match.</p>
  
  <p>I have list of brands, categories and models. If i am able to identify the terms present, then I can request elasticsearch with that field specifically
  For example, a search string of "Apple iPhone 5S", I should be able to deduce that brand=Apple.</p>
  
  <p><strong>EDIT</strong>: More details as asked in comments</p>
  
  <p><em>Structure of document:</em></p>
  
  <p>I have a single index and each document ID is the SKU of the product and it contains the following fields</p>
  
  <ol>
  <li>title (Apple iPhone 5S)</li>
  <li>brand (Apple)</li>
  <li>categ (Electronics)</li>
  <li>sub_categ (Smartphones)</li>
  <li>model (iPhone 5S)</li>
  <li>attribs (dictionary of product attributes particular to each sub_categ like {"color": "gold", "memory": "32 GB", "battery": "1570 mAh"})</li>
  <li>price</li>
  </ol>
  
  <p><em>Use Case:</em></p>
  
  <p>Now when the user searches for phrase "iphone 5s battery", elastic returns search results which returns even the phone. (I agree the relevance score matches better for battery)</p>
  
  <p>What I am trying to achieve is, I have master list of sub categories. So if any word from the search phrase is present in the master list, then i would search on elasticsearch with query ["must": {"sub_categ": "battery"}]. So the result from "Smartphones" sub category would not be fetched from elastic. I wish to replicate this across multiple fields like brand, category etc</p>
  
  <p>My question is, how do I find if brand or any other particular word from the master list if present in the search phrase quickly? The only option i could think of is, looping through the master list and check if the word is present in the search phrase. If present, then keep note of it and do the same across all master list field (brand, categ, sub categ). Then generate the query with must and then querying them. I wish to know if there is a better way of accomplishing it.</p>