title: Fuse.js : retrieve records which exactly match a multiple word search
body: <p>Using <code>Fuse.js</code> I'm trying to make a "multiple word" search in a JS object to get the records which contain exactly each word looked for.</p>
  
  <p>My data structure is the following (from <a href="http://fusejs.io/" rel="noreferrer">fuse.js</a>):</p>
  
  <pre><code>[{
      title: "The Lost Symbol",
      author: {
        firstName: "Dan",
        lastName: "Brown"
      }
   }, ...]
  </code></pre>
  
  <p>My issue is that my setup works for a one word search (<code>Brown</code> for example) but not for more (<code>Dan Brown</code> or <code>Dan Brown Vinci</code>).</p>
  
  <p>Fuse options:</p>
  
  <pre><code>{
      shouldSort: true,
      matchAllTokens: true,
      findAllMatches: true,
      includeScore: true,
      threshold: 0,
      location: 0,
      distance: 100,
      maxPatternLength: 32,
      minMatchCharLength: 1,
      keys: [
          "title",
          "author.firstName",
          "author.lastName"
      ]
  }
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>new Vue({
      el: "#app",
      data: {
          Fuse: null,
          searchText: '',
          result : [],
          fuseOptions: {
              shouldSort: true,
              matchAllTokens: true,
              findAllMatches: true,
              includeScore: true,
              threshold: 0,
              location: 0,
              distance: 100,
              maxPatternLength: 32,
              minMatchCharLength: 1,
              keys: [
                  "title",
                  "author.firstName",
                  "author.lastName"
              ]
          },
          list: [{
                  title: "Old Man's War",
                  author: {
                      firstName: "John",
                      lastName: "Scalzi"
                  }
              },
              {
                  title: "The Lock Artist",
                  author: {
                      firstName: "Steve",
                      lastName: "Hamilton"
                  }
              },
              {
                  title: "HTML5",
                  author: {
                      firstName: "Remy",
                      lastName: "Sharp"
                  }
              },
              {
                  title: "Right Ho Jeeves",
                  author: {
                      firstName: "P.D",
                      lastName: "Woodhouse"
                  }
              },
              {
                  title: "The Code of the Wooster",
                  author: {
                      firstName: "P.D",
                      lastName: "Woodhouse"
                  }
              },
              {
                  title: "Thank You Jeeves",
                  author: {
                      firstName: "P.D",
                      lastName: "Woodhouse"
                  }
              },
              {
                  title: "The DaVinci Code",
                  author: {
                      firstName: "Dan",
                      lastName: "Brown"
                  }
              },
              {
                  title: "Angels &amp; Demons",
                  author: {
                      firstName: "Dan",
                      lastName: "Brown"
                  }
              },
              {
                  title: "The Silmarillion",
                  author: {
                      firstName: "J.R.R",
                      lastName: "Tolkien"
                  }
              },
              {
                  title: "Syrup",
                  author: {
                      firstName: "Max",
                      lastName: "Barry"
                  }
              },
              {
                  title: "The Lost Symbol",
                  author: {
                      firstName: "Dan",
                      lastName: "Brown"
                  }
              },
              {
                  title: "The Book of Lies",
                  author: {
                      firstName: "Brad",
                      lastName: "Meltzer"
                  }
              },
              {
                  title: "Lamb",
                  author: {
                      firstName: "Christopher",
                      lastName: "Moore"
                  }
              },
              {
                  title: "Fool",
                  author: {
                      firstName: "Christopher",
                      lastName: "Moore"
                  }
              },
              {
                  title: "Incompetence",
                  author: {
                      firstName: "Rob",
                      lastName: "Grant"
                  }
              },
              {
                  title: "Fat",
                  author: {
                      firstName: "Rob",
                      lastName: "Grant"
                  }
              },
              {
                  title: "Colony",
                  author: {
                      firstName: "Rob",
                      lastName: "Grant"
                  }
              },
              {
                  title: "Backwards, Red Dwarf",
                  author: {
                      firstName: "Rob",
                      lastName: "Grant"
                  }
              },
              {
                  title: "The Grand Design",
                  author: {
                      firstName: "Stephen",
                      lastName: "Hawking"
                  }
              },
              {
                  title: "The Book of Samson",
                  author: {
                      firstName: "David",
                      lastName: "Maine"
                  }
              },
              {
                  title: "The Preservationist",
                  author: {
                      firstName: "David",
                      lastName: "Maine"
                  }
              },
              {
                  title: "Fallen",
                  author: {
                      firstName: "David",
                      lastName: "Maine"
                  }
              },
              {
                  title: "Monster 1959",
                  author: {
                      firstName: "David",
                      lastName: "Maine"
                  }
              }
          ]
  
      },
      methods: {
          fuseSearch: function() {
              let self = this;
              
              this.result = this.Fuse.search(self.searchText)
          }
      },
  
      mounted() {
        let self = this
          this.Fuse = new window.Fuse(self.list, self.fuseOptions);
          
  
      }
  })</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    background: #20262E;
    padding: 20px;
    font-family: Helvetica;
  }
  
  #app {
    background: #fff;
    border-radius: 4px;
    padding: 20px;
    transition: all 0.2s;
  }
  
  table {
    width: 100%;
    margin-top:20px
  }
  
  table th{
    font-weight:bold
  }
  table td{
    padding-top:5px
  }
  
  input{
    height:30px;
    width:200px;
    font-size:14px
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.2.1/fuse.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"&gt;&lt;/script&gt;
  
  &lt;div id="app"&gt;
    &lt;input type="text" v-model="searchText" @keyup="fuseSearch()" placeholder="search for text"&gt;
    
    
    &lt;div v-if="result.length == 0" style="margin-top:10px"&gt;No matching results, here is the full list&lt;/div&gt;
    &lt;div v-else style="margin-top:10px"&gt;{{result.length}} records found&lt;/div&gt;
    
    
    
    &lt;table&gt;
      &lt;tr&gt;
        &lt;th&gt;Title&lt;/th&gt;
        &lt;th&gt;FistName&lt;/th&gt;
        &lt;th&gt;LastName&lt;/th&gt;
        &lt;th&gt;Score&lt;/th&gt;
      &lt;/tr&gt;
      
      &lt;tr v-if="result.length &gt;0" v-for="data in result" &gt;
        &lt;td&gt;{{data.item.title}}&lt;/td&gt;
        &lt;td&gt;{{data.item.author.firstName}}&lt;/td&gt;
        &lt;td&gt;{{data.item.author.lastName}}&lt;/td&gt;
        &lt;td&gt;{{Math.round(data.score*100,2)/100}}&lt;/td&gt;
      &lt;/tr&gt;
      
      &lt;tr v-if="result.length == 0" v-for="data in list"&gt;
      
        &lt;td&gt;{{data.title}}&lt;/td&gt;
        &lt;td&gt;{{data.author.firstName}}&lt;/td&gt;
        &lt;td&gt;{{data.author.lastName}}&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>