diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-12-23 04:38:56 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-12-23 04:38:56 +0900 |
| commit | 7cf4aa9f110cebf1bf3017471b8e96d2522ad462 (patch) | |
| tree | 0686d36a974724ebb91e9ec5d6973b0d60a0a360 /src | |
| parent | oops (diff) | |
| download | sharkey-7cf4aa9f110cebf1bf3017471b8e96d2522ad462.tar.gz sharkey-7cf4aa9f110cebf1bf3017471b8e96d2522ad462.tar.bz2 sharkey-7cf4aa9f110cebf1bf3017471b8e96d2522ad462.zip | |
#1034
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/endpoints/posts/search.ts | 24 | ||||
| -rw-r--r-- | src/web/docs/search.ja.pug | 5 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index 6cea5bdf53..26675989dd 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -97,14 +97,22 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo const push = x => q.$and.push(x); if (text) { - push({ - $and: text.split(' ').map(x => ({ - // キーワードが-で始まる場合そのキーワードを除外する - text: x[0] == '-' ? { - $not: new RegExp(escapeRegexp(x.substr(1))) - } : new RegExp(escapeRegexp(x)) - })) - }); + // 完全一致検索 + if (/"""(.+?)"""/.test(text)) { + const x = text.match(/"""(.+?)"""/)[1]; + push({ + text: x + }); + } else { + push({ + $and: text.split(' ').map(x => ({ + // キーワードが-で始まる場合そのキーワードを除外する + text: x[0] == '-' ? { + $not: new RegExp(escapeRegexp(x.substr(1))) + } : new RegExp(escapeRegexp(x)) + })) + }); + } } if (userId) { diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 09173a3503..9e64789488 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -12,6 +12,11 @@ section code git -コミット section + h2 完全一致 + p テキストを「"""」で囲むと、そのテキストと完全に一致する投稿を検索します。 + p 例えば、「"""にゃーん"""」と検索すると、「にゃーん」という投稿のみがヒットし、「にゃーん…」という投稿はヒットしません。 + +section h2 オプション p | オプションを使用して、より高度な検索を行えます。 |