1

特定の文字を使用して完全な検索列内を検索したい、つまり:

select "Name","Country","_score" from datatable where match("Country", 'China');

多くの行を返し、問題ありません。私の質問は、たとえばどのように検索できますか?

select "Name","Country","_score" from datatable where match("Country", 'Ch');

見たい、中国、チリなど

match_type phrase_prefix が答えになると思いますが、どのように使用できるか(正しい構文)がわかりません。

4

2 に答える 2

1

一致述語は、 を使用してさまざまなタイプをサポートしますusing match_type [with (match_parameter = [value])]

したがって、phrase_prefix一致タイプを使用した例では:

select "Name","Country","_score" from datatable where match("Country", 'Ch') using phrase_prefix;

あなたの望む結果をもたらします。

match predicateドキュメントを参照してください: https://crate.io/docs/en/latest/sql/fulltext.html?#match-predicate

于 2015-05-07T07:46:32.277 に答える
0

文字列列の先頭を一致させるだけであれば、全文分析列は必要ありません。代わりにLIKE 演算子を使用できます。たとえば、次のようになります。

cr> create table names_table (name string, country string);
CREATE OK (0.840 sec)

cr> insert into names_table (name, country) values ('foo', 'China'), ('bar','Chile'), ('foobar', 'Austria');
INSERT OK, 3 rows affected (0.049 sec)

cr> select * from names_table where country like 'Ch%';
+---------+------+
| country | name |
+---------+------+
| Chile   | bar  |
| China   | foo  |
+---------+------+
SELECT 2 rows in set (0.037 sec)
于 2015-05-07T06:52:48.087 に答える