title: Elasticsearch completion by url
body: <p>Using nodejs elasticsearch api I am trying to get completion by url. The problem is when I am trying to define the way the autocompletion should work, it splits my url in several chuncks, not the whole url:</p>
  
  <p>E,g: URL=<a href="https://www.edx.org/course/introduction-mongodb-using-mean-stack-mongodbx-m101x-0" rel="nofollow">https://www.edx.org/course/introduction-mongodb-using-mean-stack-mongodbx-m101x-0</a></p>
  
  <p>This is the index that I created:</p>
  
  <pre><code>elasticClient.index({
  index: indexName,
  type: 'mooc',
  body: {
    name: document.name,
    url: document.url,
    platform: document.platform,
    idMooc: document.idMooc,
    platformId: document.platformId,
    duration: document.duration,
    points: document.points,
    tags: document.tags,
    dirty: document.dirty,
    area: document.area,
    description: document.description,
    suggest: {
      input: document.name.split(' '),
      output: document.name,
      payload: document || {}
    },
    urlsuggest:{
      input: document.url,
      output: document.url,
      payload: document || {}
    }
  }
  })
  </code></pre>
  
  <p>This is my search:</p>
  
  <pre><code>elasticClient.search({
  index: indexName,
  type: 'mooc',
  body: {
    query: {
      filtered: {
        query: {
          match: {
            // match the query agains all of
            // the fields in the posts index
            _all: input
          }
        },
        filter: {
          // only return documents that the flag dirty is false
          term: { dirty: false }
        }
      }
    },
    suggest: {
      urlsuggest: {
        text: input,
        term: {
          field: 'urlsuggest'
        }
      }
    }
  }
  })
  </code></pre>
  
  <p>I got the following urlsuggest:</p>
  
  <pre><code>"suggest":{  
    "urlsuggest":[  
       {  
          "text":"https",
          "offset":0,
          "length":5,
          "options":[  
  
          ]
       },
       {  
          "text":"www",
          "offset":8,
          "length":3,
          "options":[  
  
          ]
       },
       {  
          "text":"edx",
          "offset":12,
          "length":3,
          "options":[  
  
          ]
       },
       {  
          "text":"org",
          "offset":16,
          "length":3,
          "options":[  
  
          ]
       },
       {  
          "text":"course",
          "offset":20,
          "length":6,
          "options":[  
  
          ]
       },
       {  
          "text":"introduction",
          "offset":27,
          "length":12,
          "options":[  
  
          ]
       },
       {  
          "text":"mongodb",
          "offset":40,
          "length":7,
          "options":[  
  
          ]
       },
       {  
          "text":"using",
          "offset":48,
          "length":5,
          "options":[  
  
          ]
       },
       {  
          "text":"mean",
          "offset":54,
          "length":4,
          "options":[  
  
          ]
       },
       {  
          "text":"stack",
          "offset":59,
          "length":5,
          "options":[  
  
          ]
       },
       {  
          "text":"mongodbx",
          "offset":65,
          "length":8,
          "options":[  
  
          ]
       },
       {  
          "text":"m",
          "offset":74,
          "length":1,
          "options":[  
  
          ]
       },
       {  
          "text":"x",
          "offset":78,
          "length":1,
          "options":[  
  
          ]
       }
    ]
    }
  </code></pre>
  
  <p>Which, for some reason splits my url in many inputs. Apart from that is not finding properly since it does not find any match and my elasticsearch contains that field and was properly populated.</p>