0

solr の構文エラーの包括的なリストがあるかどうかを確認しようとしています。私の目標は、構文エラーが発生しないように、フロントエンド ユーザーのクエリを「クリーンアップ」する関数を作成することです。

これまでのところ、次の 2 つのエラーが見つかりました。

EOF

クエリが大文字の AND、OR、NOT などで終わる場合、EOF エラーがスローされます。
修正: 小文字のクエリ (クエリは大文字と小文字を区別しないように設定されているため)

未確認のフィールド情報

「長い学術タイトルの開始: ここに機知に富んだサブタイトル」のように、クエリにコロンが含まれている場合。
修正:: のすべてのインスタンスをスペースに置き換えます。

これで修正が必要な問題がすべて解決したことを願っていますが、他にも solr 構文エラーを認識して管理する必要がある場合は、非常に役立ちます。

4

1 に答える 1

0

構文エラーの包括的なリストがあるかどうかはわかりませんが、対処したものをいくつか示します。

1) encoding issues: special characters like %, & etc should not be
passed as it is as they may ruin the whole query

2) cases of two asterisks together: ** may cause infinite loops or
put the system down to its knees, if leading and trailing wildcards
are accepted. Case when a search term is just one asterisk isn't
allowed in our system either

3) (optionally) for boolean queries ensure that opening and closing
brackets match

4) strip the punctuation, but do it with care, e.g. if U.S. turns
into US, then to ensure findability (recall matters to us), we make
sure same happens during the tokenization. Also we identify urls and
don't remove punctuation from them

5) some errors may relate to malformed proximity operators (like
near, ~), e.g. we don't allow them to be nested or boolean operators
inside them

また、一部の構文エラーは、ユーザー向けに独自に定義した構文に照らして制御できると言えます。つまり、許可したくないことは許可しないということです。これにより、ユーザーとアプリケーションの間である種の検索契約も形成されます。また、どのような一般的な構文をどのような目的で使用できるかをユーザーに伝えるツールチップのような情報を提供することもお勧めします。

于 2012-08-31T19:22:41.003 に答える