title: Firestore - Simple full text search solution
body: <p>I know that firestore doesn't support full text search and it giving us solution to use third party services. However I found a simple solution to <em>simple</em> "full text search" and I think this might help others who doesn't want to use third party services as me for such a simple task. 
  I'm trying to search for company name which is saved in firestore collection under my companyName which can be in any format for example "My Awesome Company". When adding new company with companyName or updating a value in companyName I'm also saving searchName with it which is the same value as company name but in lower case without spaces</p>
  
  <pre><code>searchName: removeSpace(companyName).toLowerCase() 
  </code></pre>
  
  <p>removeSpace is my simple custom function which remove all spaces from a text</p>
  
  <pre><code>export const removeSpace = (string) =&gt; {
      return string.replace(/\s/g, '');
  }
  </code></pre>
  
  <p>That turns our company name to <strong>myawesomecompany</strong> which is saved in searchName</p>
  
  <p>Now I've got a firestore function to search for company which indexing through searchName and returning companyName. Minumum search value is a searched value without last character and maximum search value is a searched value with added "zzzzzzzzzzzzzzzzzzzzzzzz" transformed to lower case. That means if you search for <strong>My Aw</strong> then min value will be <strong>mya</strong> and max value will be <strong>myawzzzzzzzzzzzzzzzzzzzzzzz</strong></p>
  
  <pre><code>exports.handler = ((data) =&gt; {
  const searchValue = data.value.replace(/\s/g, '').toLowerCase()
  const minName = searchValue.substr(0, searchName.length-1)
  const maxName = searchValue + "zzzzzzzzzzzzzzzzzzzzzzzz"
  let list = []
  const newRef = db.collection("user").where("profile.searchName", "&gt;=", minName).where("profile.searchName", "&lt;=", maxName)
  return newRef.get()
  .then(querySnapshot =&gt; {
      querySnapshot.forEach(doc =&gt; {
          list.push({ name: doc.data().profile.companyName})
      })
      return list
  })
  })
  </code></pre>
  
  <p>I didn't have time to fully test it but so far it works without any problems. Please let me know if you spot anything wrong with it. Now the question is </p>
  
  <p>Is "z" character the highest value character in firestore or is there any other more decent way to add into the search value maximum amount without adding "zzzzzzzzzzzzz"?</p>