[Code] Make file and repository typeahead query case insensitive (#37399) (#37429)

This commit is contained in:
Mengwei Ding 2019-05-29 22:17:05 -07:00 committed by GitHub
parent 0a3d209b13
commit b533ab9298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -239,6 +239,8 @@ export class DocumentSearchClient extends AbstractSearchClient {
? DocumentSearchIndexWithScope(req.repoScope)
: `${DocumentIndexNamePrefix}*`;
const queryStr = req.query.toLowerCase();
const rawRes = await this.client.search({
index,
body: {
@ -250,7 +252,7 @@ export class DocumentSearchClient extends AbstractSearchClient {
{
prefix: {
'path.hierarchy': {
value: req.query,
value: queryStr,
boost: 1.0,
},
},
@ -258,7 +260,7 @@ export class DocumentSearchClient extends AbstractSearchClient {
{
term: {
'path.hierarchy': {
value: req.query,
value: queryStr,
boost: 10.0,
},
},

View file

@ -28,6 +28,8 @@ export class RepositorySearchClient extends AbstractSearchClient {
? RepositorySearchIndexWithScope(req.repoScope)
: `${RepositoryIndexNamePrefix}*`;
const queryStr = req.query.toLowerCase();
const rawRes = await this.client.search({
index,
body: {
@ -38,7 +40,7 @@ export class RepositorySearchClient extends AbstractSearchClient {
should: [
{
simple_query_string: {
query: req.query,
query: queryStr,
fields: [
`${RepositoryReservedField}.name^1.0`,
`${RepositoryReservedField}.org^1.0`,
@ -53,7 +55,7 @@ export class RepositorySearchClient extends AbstractSearchClient {
{
prefix: {
[`${RepositoryReservedField}.name`]: {
value: req.query,
value: queryStr,
boost: 100.0,
},
},