bitte verwendet nur noch addressen die https beginnen! Siehe wiki https://wiki.mediacube.at/wiki/index.php?title=Repositories#ssh-_vs._https_repository_adressen

alle von MMT haben hier Zugriff. Du willst Deine Freunde von MMA auch dabei haben? Mail mit den usernamen an Brigitte Jellinek

Commit 966d5555 authored by Daniel Witek's avatar Daniel Witek

add spellcheck

parent cd7057bc
const solr = require('solr-client');
const $ = require('jquery');
const client = solr.createClient('127.0.0.1', '8983', 'gettingstarted', '/solr');
// const startQuery = `q=id:3`;
// // DisMax query
// var query = client.createQuery()
// .q('water')
// .dismax()
// .qf({poke_txt_en : 0.2 , about_txt_en : 3.3})
// .mm(2)
// .start(0)
// .rows(10);
// client.search(query,function(err,obj){
// if(err){
// console.log(err);
// }else{
// console.log(obj);
// }
// });
// Lucene query
// var query2 = client.createQuery()
// .q({poke_txt_en : 'bulbasaur'})
// .start(0)
// .rows(10);
let filter
$("select").change(function(){
filter=$("select").val()
});
let searchButton = document.getElementById('searchButton')
searchButton.addEventListener("click", search, false)
function search(e) {
e.preventDefault();
const searchValue = document.getElementById('input').value
console.log(searchValue);
clearList();
sendNameQuery(searchValue);
sendSpellcheck(searchValue);
}
function clearList() {
document.getElementById("results").innerHTML = ""
}
// $('searchForm').submit(function(){
//
// console.log(searchValue);
// console.log($('#input').val());
// sendQuery($('#input').val())
// console.log($('#input').val());
// // return false
// })
function sendNameQuery(q){
if(q.length==0){
document.getElementById("results").innerHTML = "Bitte gib' einen Suchbegriff ein!"
}else{
//var query = "q=about_txt_en:("+ q +")&rows=100" //rows ist nötig, sonst nur 10 results
var query = client.createQuery()
.q(q)
.dismax()
.qf({poke_txt_en : 0.2 , about_txt_en : 3.3})
.start(0)
.rows(10)
if(filter)
query.matchFilter('types_features_str', filter)
// console.log(query);
client.search(query,function(err,obj){
if(err){
console.log(err);
}else{
results = obj.response.docs
if (results.length == 0) {
document.getElementById("results").innerHTML = "No results"
}
else{
obj.response.docs.forEach(function(entry){
let item = document.createElement("p")
item.innerHTML =
"<li>Id: <strong>" + entry.id + "</strong></li>" +
"<li>Name: <strong>" + entry.poke_txt_en + "</strong></li>" +
"<li>Description: " + entry.about_txt_en + "</li>" +
"<li>Gen: " + entry.gen_txt_en + "</li>" +
"<li>MaxHP: " + entry.maxHP_txt_en + "</li>" +
"<li>MaxCP: " + entry.maxCP_txt_en + "</li>" +
"<li>Types:</li>" +
`<ul id='${entry.id}'></ul>`;
document.getElementById('results').appendChild(item)
entry.types_features.forEach(function(type){
let item3 = document.createElement("li")
item3.innerHTML = type;
document.getElementById(entry.id).appendChild(item3)
})
// 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 +=", "
}
}});
}
* {
margin: 0;
}
body{
background-color: #CB2D36;
color: white;
font-family: 'Raleway', sans-serif;
}
.title{
font-size: 3em;
padding: 0.2em;
border-bottom: solid;
border-right: solid;
border-color: black;
border-bottom-right-radius: 1em;
width: 40%;
background-color: #b62830;
display: flex;
}
.blue_dot{
width: 0.8em;
height: 0.8em;
border-radius: 50%;
background-color: #6AE8F2;
border-color: black;
border-style: solid;
margin-right: 0.5em;
}
.search{
padding-top: 2em;
display: flex;
justify-content: center;
}
.searchForm{
display: flex;
flex-direction: column;
justify-content: center;
background-color: #6AE8F2;
width: 40%;
padding: 1em;
border-bottom-left-radius: 1em;
color: black;
border-style: solid;
border-width: 2px;
font-size: 1.2em;
}
.formelement{
width: 20em;
height: 2em;
margin-top: 1em;
}
\ No newline at end of file
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