title: OR Query mongodb from java with "like" and "line break" and "case insensitive" at the same time
body: <p>This is sample of one document in my mongodb collection page_link_titles:</p>
  
  <pre><code>{
      "_id" : ObjectId("553b11f30b81511d64152416"),
      "id" : 36470831,
      "linkTitles" : [ 
          "Syrian civil war", 
          "Damascus", 
          "Geographic coordinate system", 
          "Bashar al-Assad", 
          "Al Jazeera English", 
          "Free Syrian Army", 
          ...
  
          "February 2012 Aleppo bombings", 
          "2012 Deir ez-Zor bombing", 
          "Aleppo University bombings"
      ]
  }
  </code></pre>
  
  <p>I want to find all the documents that the text in their <code>linkTitles</code> contains a phrase like <code>'%term1%'</code> or <code>'%term2%'</code> or (so on). term1 and term2 must have a line break in both sides. For example looking into <code>"Syrian civil war"</code>. If <code>term1 = "war"</code> I want this document to be returned as the result of query, however if <code>term1 = "yria"</code> which is a part of a word in this document, it shouldn't be returned.</p>
  
  <p>This is my java code:</p>
  
  <pre><code>for (String term : segment.terms) {
      DBObject clause1 = new BasicDBObject("linkTitles",
              java.util.regex.Pattern.compile("\\b"
                      + stprocess.singularize(term) + "\\b"));
      or.add(clause1);
  }
  
  DBObject mongoQuery = new BasicDBObject("$or", or);
  DBCursor cursor = pageLinks.find(mongoQuery);
  </code></pre>
  
  <p>In line: <code>java.util.regex.Pattern.compile("\\b"+ stprocess.singularize(term) + "\\b"));</code> I only assumed line break. I don't know how I should write the regex to consider all my conditions : <a href="https://stackoverflow.com/questions/29976711/java-mongo-db-regular-expression-non-letter-character">line break</a>, <a href="https://stackoverflow.com/questions/1863399/mongodb-is-it-possible-to-make-a-case-insensitive-query">case insensitive</a>, <a href="https://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like">like</a>.</p>
  
  <p>Any ideas?</p>