Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f9654b78

Přidáno uživatelem Jitka Poubová před téměř 5 roky(ů)

Re #8030: Checkbox pro spell checker BE
- na BE přidána podmínka, zda-li je spellcheck zapnutý či ne

Zobrazit rozdíly:

be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/IndexController.java
24 24
        LOG.trace("Method index called");
25 25
        try {
26 26
            LOG.debug("Calling SolrService and its Query method");
27
            return solrService.query(searchRequest.getExpression());
27
            return solrService.query(searchRequest);
28 28
        } catch (Exception e) {
29 29
            LOG.error("Cannot get method Query from SolrService returning NULL");
30 30
            LOG.error(e.toString());
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/SolrService.java
1 1
package cz.zcu.kiv.aswi.fulltextsearch;
2 2

  
3 3
import cz.zcu.kiv.aswi.fulltextsearch.document.*;
4
import cz.zcu.kiv.aswi.fulltextsearch.model.SearchRequest;
4 5
import cz.zcu.kiv.aswi.fulltextsearch.model.SearchResponse;
5 6
import javaxt.io.Image;
6 7
import org.apache.solr.client.solrj.SolrQuery;
......
269 270
        return (byte[]) result.getFieldValue(FIELD_IMG_CONTENT);
270 271
    }
271 272

  
272
    public SearchResponse query(String query) throws IOException, SolrServerException  {
273
    public SearchResponse query(SearchRequest searchRequest) throws IOException, SolrServerException  {
273 274
        LOG.trace("SolrService method query called");
274 275
        LOG.debug("Processing query - creating Solr query");
275 276

  
276
        query = query.toLowerCase();
277
        String query = searchRequest.getExpression().toLowerCase();
277 278
        SolrQuery solrQuery = new SolrQuery();
278 279
        solrQuery.set("q", FIELD_TEXT_REGION + ":" + query);
279 280
        solrQuery.setHighlight(true);
......
288 289
        Map<String, Map<String, List<String>>> highlight = response.getHighlighting();
289 290

  
290 291
        // if no documents found, try spell checking and call query again with first alternative
291
        if (docList.size() < 1) {
292
        if (searchRequest.isEnableSpellCheck() && docList.size() < 1) {
292 293
            LOG.info("No documents found, trying spell check...");
293 294
            SpellCheckResponse spellCheck = response.getSpellCheckResponse();
294 295

  
......
299 300
                if (alternatives.size() > 0) {
300 301
                    String alternative = alternatives.get(0);
301 302
                    LOG.info("Spell check found alternative \"" + alternative + "\", calling query again with this alternative as parameter.");
302
                    return query(alternative);
303
                    return query(new SearchRequest(alternative, searchRequest.getTimestamp(), false));
303 304
                }
304 305
            }
305 306

  
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/model/SearchRequest.java
6 6

  
7 7
    private String expression;
8 8
    private Date timestamp;
9
    private boolean enableSpellCheck;
9 10

  
10
    public SearchRequest(String expression, Date timestamp) {
11
    public SearchRequest(String expression, Date timestamp, boolean enableSpellCheck) {
11 12
        this.expression = expression;
12 13
        this.timestamp = timestamp;
14
        this.enableSpellCheck = enableSpellCheck;
13 15
    }
14 16

  
15 17
    public String getExpression() {
......
24 26
        return timestamp;
25 27
    }
26 28

  
27
    public void setTimestamp(Date timestamp) {
28
        this.timestamp = timestamp;
29
    public boolean isEnableSpellCheck() {
30
        return enableSpellCheck;
29 31
    }
30 32
}

Také k dispozici: Unified diff