title: Using lucene to search data differently for different users conditionally
body: <p>Consider that the entities that I need to perform text search are as following</p>
  
  <pre><code>Sample{
      int ID, //Unique ID
      string Name,//Searchable field
      string Description //Searchable field
  }
  </code></pre>
  
  <p>Now, I have several such entities which are commonly shared by all the users but each user can associate different tags, Notes etc to any of these entities. For simplicity lets say a user can add tags to a Sample entity.</p>
  
  <pre><code>UserSampleData{
      int ID, //Sample ID
      int UserID, //For condition
      string tags //Searchable field
  }
  </code></pre>
  
  <p>When a user performs search, I want to search for the given string in the fields Name, Description and tags associated to that Sample by the current user. I am pretty new to using lucene indexing and I am not able to figure how can I design a index and also the queries for such a situation. I need the results sorted on the relevance with the search query. Following approaches crossed my mind, but I have a feeling there could be better solutions:</p>
  
  <ol>
  <li>Separately query 2 different entities Samples and UserSampleData and somehow mix the 2 results. For the results that intersect, we need to combine the match scores by may be averaging.
  
  <ol start="2">
  <li>Flatten out the data by combining both the entities => multiple entries for same ID.</li>
  </ol></li>
  </ol>