Commit a408c130 authored by Daniel Witek's avatar Daniel Witek

added highlighting

parent 2c618b38
......@@ -66,6 +66,11 @@ function sendNameQuery(q){
.q(q)
.dismax()
.qf({poke_txt_en : 0.2 , about_txt_en : 3.3})
.set(`hl.fl=about_txt_en`)
.set(`hl=on`)
.set(`hl.snippets=10`)
.set(`hl.simple.pre=<b>`)
.set(`hl.simple.post=</b>`)
.start(0)
.rows(10)
if(filter)
......@@ -78,16 +83,28 @@ function sendNameQuery(q){
}else{
results = obj.response.docs
highlight = obj.highlighting
if (results.length == 0) {
document.getElementById("results").innerHTML = "No results"
}
else{
obj.response.docs.forEach(function(entry){
let item = document.createElement("p")
let high = highlight[entry.id].about_txt_en
console.log(high)
let snippets = ""
for (var i = 0; i < high.length; i++) {
let h = "<li class='poke_about'><i>" + high[i] + "</i></li>"
snippets += h
}
item.innerHTML =
"<li class='poke_title'><strong>" + entry.id + " " + entry.poke_txt_en + "</strong></li>" +
"<li class='poke_about'><i>" + entry.about_txt_en + "</i></li>" +
snippets +
// "<li class='poke_about'><i>" + highlight[entry.id] + "</i></li>" +
"<li>" + entry.gen_txt_en + " Pokémon</li>" +
"<li>MaxHP: " + entry.maxHP_txt_en + "</li>" +
"<li>MaxCP: " + entry.maxCP_txt_en + "</li>" +
......@@ -132,7 +149,7 @@ function sendSpellcheck(spell){
if(suggest.length > 1) document.getElementById("suggestions").innerHTML = "Spellcheck: "
for (var i = 1; i < suggest.length; i++) {
let test= suggest[i].collationQuery
console.log(test)
// console.log(test)
let word = document.createElement("li")
i++;
word.innerHTML = test;
......
......@@ -93,4 +93,5 @@ li{
.poke_about{
padding-bottom: 0.5em;
list-style: circle;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment