Javascript 通过url完成Elasticsearch
使用nodejselasticsearch api,我试图通过url来完成。问题是,当我试图定义自动完成的工作方式时,它会将我的url分成几个部分,而不是整个url: E、 g:URL= 这是我创建的索引:Javascript 通过url完成Elasticsearch,javascript,node.js,elasticsearch,Javascript,Node.js,elasticsearch,使用nodejselasticsearch api,我试图通过url来完成。问题是,当我试图定义自动完成的工作方式时,它会将我的url分成几个部分,而不是整个url: E、 g:URL= 这是我创建的索引: elasticClient.index({ index: indexName, type: 'mooc', body: { name: document.name, url: document.url, platform: document.platform, idMooc:
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 || {}
}
}
})
这是我的搜索:
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'
}
}
}
}
})
我得到以下建议:
"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":[
]
}
]
}
出于某种原因,它将我的url拆分为许多输入。除此之外,由于找不到任何匹配项,并且my elasticsearch包含该字段,并且已正确填充,因此无法正确查找。在搜索查询中,尝试将字段“urlsimprove”更改为字段“url”?在搜索查询中,尝试将字段“urlsimprove”更改为字段:“url”?