Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple file search #13

Closed
YunFeng0817 opened this issue Feb 8, 2021 · 14 comments · Fixed by #199
Closed

Support multiple file search #13

YunFeng0817 opened this issue Feb 8, 2021 · 14 comments · Fixed by #199
Assignees
Labels
enhancement New feature or request
Projects

Comments

@YunFeng0817
Copy link

It looks like the current file search range is limited to opened files and I hope it will be able to search in the entire project.
image

@conwnet
Copy link
Owner

conwnet commented Feb 9, 2021

This feature will be supported it in the near future, I need to think about how to do it...

@xcv58 xcv58 added the enhancement New feature or request label Feb 11, 2021
@khg0712
Copy link

khg0712 commented Feb 16, 2021

🚀🚀🚀

@conwnet conwnet added this to To do in Roadmap Feb 20, 2021
@conwnet conwnet moved this from To do to In Progress in Roadmap Feb 24, 2021
@conwnet conwnet self-assigned this Feb 24, 2021
@rish07
Copy link

rish07 commented Feb 24, 2021

@conwnet is someone working on this issue? If not I'd like to contribute

@conwnet
Copy link
Owner

conwnet commented Feb 24, 2021

is someone working on this issue? If not I'd like to contribute

@rish07

Thank you, it hasn't started yet, how do you want to do this?

I read the documentation of Search Code, It seems only default branch are supported by this API.
also the RegExp, caseSensitive options are not supported.

Sure, search supported for the default branch also is a lot of help.

For other branch, we can only search text in the files which we have already cache it.

Another way is we use GraphQL API to fetch all files' content, should we?

@rish07
Copy link

rish07 commented Feb 24, 2021

I did go through the Search code's documentation as well and you're right there. How would you use GraphQL API for this?

@conwnet
Copy link
Owner

conwnet commented Feb 24, 2021

I did go through the Search code's documentation as well and you're right there. How would you use GraphQL API for this?

Use the GraphQL API to get contents of all files...😂 It's just a guess, the performance is too low in this way.
I think we should use the the REST Search API to implement the first version too.

@rish07
Copy link

rish07 commented Feb 24, 2021

Yes I think so too. Is there a community for this repo like slack or discord or something where we can discuss?

@conwnet
Copy link
Owner

conwnet commented Feb 24, 2021

Yes I think so too. Is there a community for this repo like slack or discord or something where we can discuss?

thanks, good idea~ I create an community here https://gitter.im/conwnet/github1s

@conwnet conwnet assigned rish07 and unassigned conwnet Feb 24, 2021
@Siddhant-K-code
Copy link
Collaborator

I create an community here https://gitter.im/conwnet/github1s

@xcv58 Please Join This Community for discussion :)

@bpartridge
Copy link

bpartridge commented Feb 25, 2021

Sourcegraph's public API (which can index any public repository on demand) might be a great solution here; it supports regexes and case sensitivity, provides line numbers and offsets, and even allows searching across repos if multi-repo projects were ever something we wanted to support!

Link to a live search with capabilities highlighted (press the Play button at top to run)

https://about.sourcegraph.com/

@xcv58
Copy link
Collaborator

xcv58 commented Feb 25, 2021

Sourcegraph's public API (which can index any public repository on demand) might be a great solution here; it supports regexes and case sensitivity, provides line numbers and offsets, and even allows searching across repos if multi-repo projects were ever something we wanted to support!

Link to a live search with capabilities highlighted (press the Play button at top to run)

https://about.sourcegraph.com/

Does Sourcegraph's public API support all public repo?

@rish07
Copy link

rish07 commented Feb 26, 2021

Sourcegraph's public API (which can index any public repository on demand) might be a great solution here; it supports regexes and case sensitivity, provides line numbers and offsets, and even allows searching across repos if multi-repo projects were ever something we wanted to support!

Link to a live search with capabilities highlighted (press the Play button at top to run)

https://about.sourcegraph.com/

Wouldn't using this API require the generation of access token doing GitHub auth? https://docs.sourcegraph.com/api/graphql#quickstart

@bpartridge
Copy link

Wouldn't using this API require the generation of access token doing GitHub auth? docs.sourcegraph.com/api/graphql#quickstart

I don't believe so. From what I can tell the Sourcegraph documentation is tailored for people running it on their on infrastructure against private repos. But their public instance, which works on public repositories, doesn't require any auth. The following command will work, for instance, without any cookies or auth headers:

curl 'https://sourcegraph.com/.api/graphql' --data-binary $'{"query":"query ($query: String\u0021) {\\n  search(query: $query) {\\n    results {\\n      __typename\\n      limitHit\\n      resultCount\\n      approximateResultCount\\n      missing {\\n        name\\n      }\\n      cloning {\\n        name\\n      }\\n      timedout {\\n        name\\n      }\\n      indexUnavailable\\n      results {\\n        ... on Repository {\\n          __typename\\n          name\\n        }\\n        ... on FileMatch {\\n          __typename\\n          resource\\n          lineMatches {\\n            preview\\n            lineNumber\\n            offsetAndLengths\\n          }\\n        }\\n        ... on CommitSearchResult {\\n          __typename\\n          commit {\\n            oid\\n            message\\n          }\\n        }\\n      }\\n    }\\n  }\\n}\\n","variables":{"query":"repo:^github.com/gorilla/mux$ Router"}}'   --compressed

That said, for obscure/uncommonly used public repositories with lots of files, there may be some time required to index. I can't imagine it would be any slower, though, than trying to load the content over a client connection and index locally - and I doubt we want to run github1s servers to host indices in the cloud ourselves! Sourcegraph IMO seems like a very realistic and pragmatic compromise.

@conwnet
Copy link
Owner

conwnet commented Feb 26, 2021

Wouldn't using this API require the generation of access token doing GitHub auth? docs.sourcegraph.com/api/graphql#quickstart

I don't believe so. From what I can tell the Sourcegraph documentation is tailored for people running it on their on infrastructure against private repos. But their public instance, which works on public repositories, doesn't require any auth. The following command will work, for instance, without any cookies or auth headers:

curl 'https://sourcegraph.com/.api/graphql' --data-binary $'{"query":"query ($query: String\u0021) {\\n  search(query: $query) {\\n    results {\\n      __typename\\n      limitHit\\n      resultCount\\n      approximateResultCount\\n      missing {\\n        name\\n      }\\n      cloning {\\n        name\\n      }\\n      timedout {\\n        name\\n      }\\n      indexUnavailable\\n      results {\\n        ... on Repository {\\n          __typename\\n          name\\n        }\\n        ... on FileMatch {\\n          __typename\\n          resource\\n          lineMatches {\\n            preview\\n            lineNumber\\n            offsetAndLengths\\n          }\\n        }\\n        ... on CommitSearchResult {\\n          __typename\\n          commit {\\n            oid\\n            message\\n          }\\n        }\\n      }\\n    }\\n  }\\n}\\n","variables":{"query":"repo:^github.com/gorilla/mux$ Router"}}'   --compressed

That said, for obscure/uncommonly used public repositories with lots of files, there may be some time required to index. I can't imagine it would be any slower, though, than trying to load the content over a client connection and index locally - and I doubt we want to run github1s servers to host indices in the cloud ourselves! Sourcegraph IMO seems like a very realistic and pragmatic compromise.

Thanks @bpartridge and @sourcegraph, I have tried it, the Sourcegraph API is really powerful!

https://docs.sourcegraph.com/code_search/reference/queries

@conwnet conwnet self-assigned this Mar 1, 2021
@conwnet conwnet moved this from In Progress to Done in Roadmap Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

7 participants