Commit cd7057bc authored by Daniel Witek's avatar Daniel Witek

added spellcheck

parent d77e81f4
......@@ -9,8 +9,11 @@
<form class="searchForm" action="">
<input id="input" name="q" type="text" />
<section id="suggestions">
</section>
<label><p>Filter by type:</p>
<select name="type" id="type">
<option value="">-Zum filtern auswählen-</option>
......@@ -40,10 +43,6 @@
<section id="results">
</section>
<script src="bundle.js"></script>
......
......@@ -39,6 +39,7 @@ function search(e) {
console.log(searchValue);
clearList();
sendNameQuery(searchValue);
sendSpellcheck(searchValue);
}
function clearList() {
......@@ -61,16 +62,15 @@ function sendNameQuery(q){
//var query = "q=about_txt_en:("+ q +")&rows=100" //rows ist nötig, sonst nur 10 results
var query = client.createQuery()
.q({*q*})
.q(q)
.dismax()
.qf({poke_txt_en : 0.2 , about_txt_en : 3.3})
.mm(0)
.start(0)
.rows(10)
if(filter)
query.matchFilter('types_features_str', filter)
console.log(query);
// console.log(query);
client.search(query,function(err,obj){
if(err){
console.log(err);
......@@ -103,11 +103,41 @@ function sendNameQuery(q){
})
console.log(entry);
// console.log(entry);
})
}
}
});
}
}
function sendSpellcheck(spell){
var spell = client.createQuery()
.dismax()
.qf({poke_txt_en : 0.2 , about_txt_en : 3.3})
.start(0)
.rows(10)
.set(`spellcheck=on`)
.set(`spellcheck.q=`+spell)
if(filter)
query.matchFilter('types_features_str', filter)
client.spell(spell,function(err,obj){
if(err){
console.log(err);
}else{
suggest = obj.spellcheck.collations
// console.log(suggest[1].collationQuery)
// console.log(suggest.length)
for (var i = 1; i < suggest.length; i++) {
let test= suggest[i].collationQuery
console.log(test)
let word = document.createElement("li")
i++;
word.innerHTML = test;
document.getElementById("suggestions").appendChild(word)
// if ((i+1)<suggest.length) words +=", "
}
}});
}
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