blob: e55da49b92151ac14e6d6076534ff6716e8478b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query.parser;
import com.yahoo.language.Language;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.query.Item;
import com.yahoo.prelude.query.NullItem;
import com.yahoo.search.query.QueryTree;
import com.yahoo.search.query.parser.Parsable;
import com.yahoo.search.query.textserialize.TextSerialize;
import java.util.Set;
/**
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
* @since 5.1.4
*/
public final class ProgrammaticParser implements CustomParser {
@Override
public QueryTree parse(Parsable query) {
Item root = parse(query.getQuery(), null, null, null, null, null);
if (root == null) {
root = new NullItem();
}
return new QueryTree(root);
}
@Override
public Item parse(String queryToParse, String filterToParse, Language parsingLanguage,
IndexFacts.Session indexFacts, String defaultIndexName) {
if (queryToParse == null) return null;
return TextSerialize.parse(queryToParse);
}
}
|