title: ElasticSearch - query documents by term and field priority
body: <p>I'm currently working with elasticsearch and I'm trying to implement a query from the Java backend that will query documents from my index not only by term but by field priority as well. In my index, I have documents that have a term and a field that specifies a type.</p>
  <pre><code>e.g 
  term: &quot;Flu Shot&quot;
  type: &quot;procedure&quot;
  
  term: &quot;Fluphenazine&quot;
  type: &quot;drug&quot;
  </code></pre>
  <p>I created a query that will search by term and the elastic index will return the most relevant results matching that term. The functionality I want to create is to create a query to return results matching that same term but ordered by a priority of the 'type' field. For example when I type &quot;flu&quot; I want to get the documents with type: &quot;procedure&quot; first then after them the ones with the type &quot;drug&quot;. Currently, the index returns only documents with type &quot;drugs&quot; due to many drugs that start with &quot;flu&quot;.</p>