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

Show subprojects in search results #1866

Merged
merged 5 commits into from
Feb 28, 2016
Merged

Conversation

agjohnson
Copy link
Contributor

Currently, file/section/etc searches show results from a queried project, but it would also be helpful to display results from subprojects. This could easily be performed by appending the subproject slugs/ids to the search queries that are searching for a specific project. Display would be altered comparing the project slug, and if different, noting "from project X" in a fashion similar to the way domain objects are displayed separately in project search.

Routing

The index routing will need to be changed here as well, as it is currently per-project, which will limit project responses. Projects can be routed to their root parent projects, to keep sub/super-projects all on the same shard. However, this creates some difficulty querying from inside a subproject:

  • Which route do we use when a project has multiple parent projects and a query is requested directly for this project?
  • Do we update the indexes for each route when a project has multiple parent projects?

Indexing should be updated to respect many to many relationships between projects, and multiple indexes will be updated when updating search indexes.

  • Update search queries to include subprojects, if any
  • Also include superprojects, if any?
  • Update routing on indexing, route to parent or root parent project
  • Display results in search output with project designation
  • Correct links to subproject pages in search results

This relies on #1808 and readthedocs/readthedocs-sphinx-ext#16

In action:
screen shot 2016-02-23 at 3 13 27 pm

@agjohnson agjohnson added the Improvement Minor improvement to code label Dec 17, 2015
@agjohnson agjohnson self-assigned this Feb 15, 2016
@agjohnson agjohnson added the PR: work in progress Pull request is not ready for full review label Feb 15, 2016
@agjohnson agjohnson added this to the Search milestone Feb 15, 2016
@agjohnson agjohnson force-pushed the indoc-subproject-search branch 2 times, most recently from 43164ce to e478b0b Compare February 23, 2016 19:55
@agjohnson agjohnson added PR: ready for review Status: blocked Issue is blocked on another issue and removed PR: work in progress Pull request is not ready for full review labels Feb 23, 2016
{"match": {"title": {"query": query, "boost": 10}}},
{"match": {"headers": {"query": query, "boost": 5}}},
{"match": {"content": {"query": query}}},
{"match_phrase": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wlil likely require updating the .com's search overrides as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened an issue on corporate to track this.

@ericholscher
Copy link
Member

LGTM 👍

search_url.href = api_host;
search_url.pathname = '/api/v2/search';
search_url.search = '?q=' + query + '&project=' + project +
'&version=' + version + '&language=' + language;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how we want to eventually handle subprojects/translations with regards to the search indexes. It doesn't hurt anything here for now, but the language query param is effectively a noop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to treat translations similar to subproject, since they are each their own "project", no? I guess we'd need to re-index when the translation was added in the Admin UI, but we can address this with a larger project around fixing i18n in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for now they are just their own projects. It would be best if a super project with language fr would search for subprojects with language fr as well. Definitely part of a larger refactor though.

@agjohnson agjohnson force-pushed the indoc-subproject-search branch 2 times, most recently from 148e6e8 to 02483e0 Compare February 26, 2016 18:16
@agjohnson agjohnson removed the Status: blocked Issue is blocked on another issue label Feb 26, 2016
@agjohnson
Copy link
Contributor Author

I addressed a few issues and rebased this. #1808 and this are unblocked now.

agjohnson added a commit that referenced this pull request Feb 28, 2016
Show subprojects in search results
@agjohnson agjohnson merged commit 32cab96 into master Feb 28, 2016
@agjohnson agjohnson deleted the indoc-subproject-search branch February 28, 2016 00:54
@pgiraud
Copy link

pgiraud commented Jul 19, 2018

Can someone please confirm that it only work with sphinx and not with mkdocs?

@RichardLitt
Copy link
Member

@pgiraud This is a pretty old issue, and your comment is likely to be lost, I think. I would encourage opening a new one and linking here. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants