Elasticsearch Highlighting not working properly
I am trying exact match on numbers using the query :
{
"from":0,
"size":24,
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"+"423.0"",
"fields":,
"boost":"50"
}
}
],
"minimum_should_match":1,
"filter":[
{
"terms":{
"FOLDER_ID.keyword":[ 2, 8, 9, 12, -1 ]
}
}
]
}
},
"highlight":{
"type":"unified",
"fields":{
"*":{
}
}
}
}
Highlighting is not working as required. It is highlighting random results.
Like:
"highlight":{
"Value1":[
"<em>0</em>"
],
"Value2.keyword":[
"<em>423.0</em>"
],
"value3":[
"<em>D:\Ser\tim\tim\FileSystem\acred\temp\1541662854708</em>"
],
"value4":[
"<em>0</em>"
],
"term":[
"<em>0.0</em>"
]
}
My analyzers at index and search time are:
My search analyzer is different from my index analyzer
I have used patter capture at index analyzer and set it to false at search analyzer. Will this analyzer at search time affect my exact match query?
"analysis":{
"filter":{
"indexFilter":{
"type":"pattern_capture",
"preserve_original":true,
"patterns":[
"([@,$,%,&,!,.,#,^,*]+)",
"([-]+)",
"(\w+)"
]
},
"searchFilter":{
"type":"pattern_capture",
"preserve_original":false,
"patterns":[
"([\w,-]+)"
]
}
},
"analyzer":{
"indexAnalyzed":{
"filter":[
"indexFilter",
"lowercase"
],
"tokenizer":"whitespace"
},
"searchAnalyzed":{
"tokenizer":"whitespace",
"filter":[
"searchFilter",
"lowercase"
]
}
}
}
Thanks
elasticsearch
|
show 1 more comment
I am trying exact match on numbers using the query :
{
"from":0,
"size":24,
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"+"423.0"",
"fields":,
"boost":"50"
}
}
],
"minimum_should_match":1,
"filter":[
{
"terms":{
"FOLDER_ID.keyword":[ 2, 8, 9, 12, -1 ]
}
}
]
}
},
"highlight":{
"type":"unified",
"fields":{
"*":{
}
}
}
}
Highlighting is not working as required. It is highlighting random results.
Like:
"highlight":{
"Value1":[
"<em>0</em>"
],
"Value2.keyword":[
"<em>423.0</em>"
],
"value3":[
"<em>D:\Ser\tim\tim\FileSystem\acred\temp\1541662854708</em>"
],
"value4":[
"<em>0</em>"
],
"term":[
"<em>0.0</em>"
]
}
My analyzers at index and search time are:
My search analyzer is different from my index analyzer
I have used patter capture at index analyzer and set it to false at search analyzer. Will this analyzer at search time affect my exact match query?
"analysis":{
"filter":{
"indexFilter":{
"type":"pattern_capture",
"preserve_original":true,
"patterns":[
"([@,$,%,&,!,.,#,^,*]+)",
"([-]+)",
"(\w+)"
]
},
"searchFilter":{
"type":"pattern_capture",
"preserve_original":false,
"patterns":[
"([\w,-]+)"
]
}
},
"analyzer":{
"indexAnalyzed":{
"filter":[
"indexFilter",
"lowercase"
],
"tokenizer":"whitespace"
},
"searchAnalyzed":{
"tokenizer":"whitespace",
"filter":[
"searchFilter",
"lowercase"
]
}
}
}
Thanks
elasticsearch
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
It is always preferred to have sameanalyzerused duringsearchandindexingtime. You can try by adding"analyzer": "<your_desired_analyzer>"next toboostin the above query and see how it goes. Meanwhile I'll try at my end.
– Kamal
Nov 15 '18 at 10:49
@Kamal , could you share the official es docs which sayspreferred to have same analyzer used during search and indexing.
– Amit Khandelwal
Nov 15 '18 at 12:18
|
show 1 more comment
I am trying exact match on numbers using the query :
{
"from":0,
"size":24,
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"+"423.0"",
"fields":,
"boost":"50"
}
}
],
"minimum_should_match":1,
"filter":[
{
"terms":{
"FOLDER_ID.keyword":[ 2, 8, 9, 12, -1 ]
}
}
]
}
},
"highlight":{
"type":"unified",
"fields":{
"*":{
}
}
}
}
Highlighting is not working as required. It is highlighting random results.
Like:
"highlight":{
"Value1":[
"<em>0</em>"
],
"Value2.keyword":[
"<em>423.0</em>"
],
"value3":[
"<em>D:\Ser\tim\tim\FileSystem\acred\temp\1541662854708</em>"
],
"value4":[
"<em>0</em>"
],
"term":[
"<em>0.0</em>"
]
}
My analyzers at index and search time are:
My search analyzer is different from my index analyzer
I have used patter capture at index analyzer and set it to false at search analyzer. Will this analyzer at search time affect my exact match query?
"analysis":{
"filter":{
"indexFilter":{
"type":"pattern_capture",
"preserve_original":true,
"patterns":[
"([@,$,%,&,!,.,#,^,*]+)",
"([-]+)",
"(\w+)"
]
},
"searchFilter":{
"type":"pattern_capture",
"preserve_original":false,
"patterns":[
"([\w,-]+)"
]
}
},
"analyzer":{
"indexAnalyzed":{
"filter":[
"indexFilter",
"lowercase"
],
"tokenizer":"whitespace"
},
"searchAnalyzed":{
"tokenizer":"whitespace",
"filter":[
"searchFilter",
"lowercase"
]
}
}
}
Thanks
elasticsearch
I am trying exact match on numbers using the query :
{
"from":0,
"size":24,
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"+"423.0"",
"fields":,
"boost":"50"
}
}
],
"minimum_should_match":1,
"filter":[
{
"terms":{
"FOLDER_ID.keyword":[ 2, 8, 9, 12, -1 ]
}
}
]
}
},
"highlight":{
"type":"unified",
"fields":{
"*":{
}
}
}
}
Highlighting is not working as required. It is highlighting random results.
Like:
"highlight":{
"Value1":[
"<em>0</em>"
],
"Value2.keyword":[
"<em>423.0</em>"
],
"value3":[
"<em>D:\Ser\tim\tim\FileSystem\acred\temp\1541662854708</em>"
],
"value4":[
"<em>0</em>"
],
"term":[
"<em>0.0</em>"
]
}
My analyzers at index and search time are:
My search analyzer is different from my index analyzer
I have used patter capture at index analyzer and set it to false at search analyzer. Will this analyzer at search time affect my exact match query?
"analysis":{
"filter":{
"indexFilter":{
"type":"pattern_capture",
"preserve_original":true,
"patterns":[
"([@,$,%,&,!,.,#,^,*]+)",
"([-]+)",
"(\w+)"
]
},
"searchFilter":{
"type":"pattern_capture",
"preserve_original":false,
"patterns":[
"([\w,-]+)"
]
}
},
"analyzer":{
"indexAnalyzed":{
"filter":[
"indexFilter",
"lowercase"
],
"tokenizer":"whitespace"
},
"searchAnalyzed":{
"tokenizer":"whitespace",
"filter":[
"searchFilter",
"lowercase"
]
}
}
}
Thanks
elasticsearch
elasticsearch
edited Nov 15 '18 at 11:28
Kamal
1,7781920
1,7781920
asked Nov 15 '18 at 8:22
M NikeshM Nikesh
558
558
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
It is always preferred to have sameanalyzerused duringsearchandindexingtime. You can try by adding"analyzer": "<your_desired_analyzer>"next toboostin the above query and see how it goes. Meanwhile I'll try at my end.
– Kamal
Nov 15 '18 at 10:49
@Kamal , could you share the official es docs which sayspreferred to have same analyzer used during search and indexing.
– Amit Khandelwal
Nov 15 '18 at 12:18
|
show 1 more comment
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
It is always preferred to have sameanalyzerused duringsearchandindexingtime. You can try by adding"analyzer": "<your_desired_analyzer>"next toboostin the above query and see how it goes. Meanwhile I'll try at my end.
– Kamal
Nov 15 '18 at 10:49
@Kamal , could you share the official es docs which sayspreferred to have same analyzer used during search and indexing.
– Amit Khandelwal
Nov 15 '18 at 12:18
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
It is always preferred to have same
analyzer used during search and indexing time. You can try by adding "analyzer": "<your_desired_analyzer>" next to boost in the above query and see how it goes. Meanwhile I'll try at my end.– Kamal
Nov 15 '18 at 10:49
It is always preferred to have same
analyzer used during search and indexing time. You can try by adding "analyzer": "<your_desired_analyzer>" next to boost in the above query and see how it goes. Meanwhile I'll try at my end.– Kamal
Nov 15 '18 at 10:49
@Kamal , could you share the official es docs which says
preferred to have same analyzer used during search and indexing.– Amit Khandelwal
Nov 15 '18 at 12:18
@Kamal , could you share the official es docs which says
preferred to have same analyzer used during search and indexing.– Amit Khandelwal
Nov 15 '18 at 12:18
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315085%2felasticsearch-highlighting-not-working-properly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315085%2felasticsearch-highlighting-not-working-properly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you post a sample document along with the mapping in the question w.r.t the query. I've tried in my machine and the query you've mentioned works as expected. Also which version of ES are you using?
– Kamal
Nov 15 '18 at 9:30
I have used custom analyzers at both search and index time. This is probably affecting this case. Can I provide a search analyzer at query time?
– M Nikesh
Nov 15 '18 at 10:12
I am using Elasticsearch 6.3.2
– M Nikesh
Nov 15 '18 at 10:24
It is always preferred to have same
analyzerused duringsearchandindexingtime. You can try by adding"analyzer": "<your_desired_analyzer>"next toboostin the above query and see how it goes. Meanwhile I'll try at my end.– Kamal
Nov 15 '18 at 10:49
@Kamal , could you share the official es docs which says
preferred to have same analyzer used during search and indexing.– Amit Khandelwal
Nov 15 '18 at 12:18