Indexing source code using ES and interest in the line number

I saw this post from 2014 Source Code Index using ES
and I also saw this post from 2017 Indexing source code using ES and ingest attachment plugin
so how about now?is there any way to get the line number from the search result easily?

I think there is not much to add to @dadoonet's answers in the threads you mentioned. The best way to be able to get line numbers is to actually index this kind of information. This usually means splitting the files in lines client-side and index it as one document per line, but this makes multi-line searches more complicated in case you need them. That or some client-side display logic in your UI. Elasticsearch has no own concept for text segmentation like "lines" or "paragraphs" unless you model your data accordingly.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.