Please refer to the parent post here for context: https://blogs.msdn.microsoft.com/tapas_sahoos_blog/2017/09/11/analyzing-search-in-microsoft-team-foundation-server/
Code Search in Team Foundation Server (TFS) 2017 Update 2 has a known issue wherein you could encounter Search query failure on collections having large number of repositories (in the order of more than 100). The issue was traced to a HTTP url of the Elasticsearch query request exceeding 4096 bytes due to the large number of repository GUIDs being sent as RoutingId in the query string. This only impact Code Search in TFS 2017 Update 2. Work Item Search should continue to work.
To identify that the search query failure is related to this, you can check for the Elasticsearch logs when the failure occurs. You would see an error log in the line of - "org.jboss.netty.handler.codec.frame.TooLongFrameException: An HTTP line is larger than 4096 bytes"
The issue has been fixed for TFS 2017 Update 3 and next major release of TFS. Meanwhile, to workaround this issue in Update 2, execute the following steps:
- Stop the Elasticsearch service
- Modify the <Drive>:\Program Files\Microsoft Team Foundation Server 2015\Search\ES\elasticsearch-2.4.1\config\elasticsearch.yml file to define a larger value for http.max_initial_line_length
The default value is 4kb. Set it to some value such as 16 or 32 kb.
(If the entry is not there, simply add one)
- Start the Elasticsearch service
Verify from TFS portal to ensure Code Search is working fine.