0

When adding front matter to a markdown document in i.e. GitLab, I am able to find the property using fulltext search.

---
title: "My subject"
author: "Jane Doe"
tags:
- tag: Book
- tag: Popular
- tag: Romance
---

# Chapter 1 - This is my Markdown

At first, the solution seemed a little bit odd.

If I need to find all Popular documents, I can search for "tag: popular" but not tag:popular. This isn't much of an issue if using YAML in the front matter section, but switching to JSON is a whole other beast.

;;;
{
  "title": "My subject",
  "author": "Jane Doe",
  "tags": [
    {
      "tag": "Book"
    },
    {
      "tag": "Popular"
    },
    {
      "tag": "Romance"
    }
  ]
}
;;;


# Chapter 1 - This is my Markdown

At first, the solution seemed a little bit odd.

Then I'd really like to only search using tag:popular instead of trying to figure out the free text syntax.

Note: Neither GitLab or Azure DevOps can presently render FrontMatter in any other format than YAML. So, to avoid bad rendering, JSON FrontMatter sections needs to be hidden using [comment]:# (hide this).

[JSON]:# (
;;;
{
  "title": "My subject",
  "author": "Jane Doe",
  "tags": [
    {
      "tag": "Book"
    },
    {
      "tag": "Popular"
    },
    {
      "tag": "Romance"
    }
  ]
}
;;;
)

# Chapter 1 - This is my Markdown

At first, the solution seemed a little bit odd.

Actually, the ElasticSearch engine i Azure DevOps do index datastructures found anywhere and make them searchable properties.

However, how should ElasticSearch be configured to support this feature on other vendors such as GitLab?

Dennis
  • 871
  • 9
  • 29
  • Can you share an example of a full document containing a front-matter in JSON format? – Val May 18 '22 at 08:01
  • @val Added some plain markdown to the FrontMatter examples. – Dennis May 18 '22 at 13:05
  • Thanks, but what I'd like to see is a raw document (containing front-matter content) as it is stored into Elasticsearch – Val May 18 '22 at 13:16
  • ElasticSearch is only the index engine. I'll see if I can find some RAW-content within ElasticSearch. The examples above is the actual content stored in Git as MarkDown. – Dennis May 18 '22 at 14:47
  • 2
    ES is "only" the search engine but it's what you're using to search, so you need to show us how the content is actually indexed into ES if you want to improve it. – Val May 18 '22 at 14:56
  • So are there any documents you can show us? – Val May 24 '22 at 06:13
  • Elasticsearch supports mapping json (in other words, schema json) when you define the index. This approach is generally good for structured documents and you can use 'keyword' based search to find the documents that exactly match the tag as 'popular'. You can explore on these lines, if this context suits in your case. – Bharanidharan K May 25 '22 at 05:25

0 Answers0