# Global search for blocks with multiple keywords

**URL:** <https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621>\
**Category:** Feature archive\
**Created:** [October 26, 2020, 3:58pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621 "2020-10-26T15:58:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [October 26, 2020, 3:58pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/1 "2020-10-26T15:58:31Z")

</div>

### Use case or problem

Currently, obsidian only allow to search for multiple terms within a note. I would like to the ability to do a global search and return the result only if those term are in the same line or under the same heading.

Implementing global search for term A and term B:

1. Only return the search result if term A and term B are in the same line/block  
or

- Only return the search result if term A and term B are under the same heading

### Proposed solution

The search box can have options for filtering/toggle level of search.  
Or create new regex operator for “pseudo blocks”

### Current workaround

Using regex for return results within block/line: /.\*term A.\*term B.\*|.\*term B.\*term A.\*/

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [October 26, 2020, 5:39pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/2 "2020-10-26T17:39:30Z")

</div>

Surely you don’t need a special search syntax for search in a block? Going through the block visually is faster than typing out the search syntax, isn’t it?

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [October 26, 2020, 9:39pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/3 "2020-10-26T21:39:48Z")

</div>

I edit the request to make it more clear:

Currently, obsidian only allow to search for multiple terms within a note. I would like to the ability to do a global search and return the result only if those term are in the same line or under the same heading.

---

<div class="post-metadata">

**Author:** ![1stprinciples](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/1/67e7ee/32.png) [@1stprinciples](https://forum.obsidian.md/u/1stprinciples)\
**Post date:** [October 27, 2020, 12:55pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/4 "2020-10-27T12:55:09Z")

</div>

In some cases going over the results may not be efficient. I write everything on my daily note and then tag them appropriately (at the end of the line). If I search for a combination of words that span different lines then, that doesn’t serve my purpose 🙂

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [October 27, 2020, 12:57pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/5 "2020-10-27T12:57:44Z")

</div>

@1stprinciples: OK, whatever. It is a feature request, so why not.

---

<div class="post-metadata">

**Author:** ![octavius](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@octavius](https://forum.obsidian.md/u/octavius)\
**Post date:** [December 12, 2020, 3:31am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/6 "2020-12-12T03:31:27Z")

</div>

This is a great feature request. So surprise that only few people need it.

For example, if I have 2 ideas on today’s note and one is done:

1. balabala #idea
2. balabalabala #idea #done  
Then I cannot use a tag search to filter the ongoing idea.

I think currently Obsidian’s ‘Block’ is only a half finished function. We only have the Block Reference. We cannot search or filter based on a block, we cannot easily create a block reference by drag-drop. Hope dev team could put more effort on it.

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 3:56am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/7 "2020-12-12T03:56:14Z")

</div>

@octavius: in your example above you can search for ongoing ideas as follows:  
`tag:#idea -#done`.

As for “Hope dev team could put more effort on it.”, it’s probably not meant as such but it sounds pretty offensive. The dev team is probably one of the hardest working, most dedicated, most accessible teams around, so please be careful in your choice of words.

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 6:41am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/8 "2020-12-12T06:41:30Z")

</div>

The way you search will show results of a page. (balabala and #idea not necessarily need to be on the same block/line).

The purpose of block search for me is to find the specific argument between 2 events/phenomenon (ex: causal relationship).

Understandably that this could be solve by implementing atomic note.  
But @octavius point is that if this search function is implemented, then the utility of block-link function will increase (which i fully agreed).

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 6:55am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/9 "2020-12-12T06:55:31Z")

</div>

@GreenChocho: @octavius has not solved it with atomic notes but by using hashtags, according to his/her example. So, he/she can filter on a particular hashtag while excluding other tags, and from there he/she can analyze trends/patterns.

Can you give an example of how you specifically would do block search?

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 7:15am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/10 "2020-12-12T07:15:47Z")

</div>

Example: if i got articles on “Team Diversity”, which have argument on team dynamics and team cognition.

But i want to find causal arguments on the relationship between “Team Diversity” and “team cognition” only, then the current global search function will not be able to help. I need to use the workaround specified in the 1st post.

I think @octavius comment is the another way to utilize this search function. He/she want to search a specific block/line which have “balabala” and #idea together. (this could be very useful for a term which may have meaning in different #context, or being used in different #discipline)

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 8:23am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/11 "2020-12-12T08:23:45Z")

</div>

@GreenChocho: OK, clear. But how is that unique to block searches?

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 8:37am UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/12 "2020-12-12T08:37:04Z")

</div>

Im not sure i understand you correctly, you mean ‘why global search cannot do this?’?

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 2:19pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/13 "2020-12-12T14:19:57Z")

</div>

@GreenChocho: it is a feature request, I don’t want to make things more difficult. I was just trying understand the thinking, but it seems I am missing a point and am therefore making things difficult.

It is probably best to leave it at this. I want to thank you for your patience.

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 3:16pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/14 "2020-12-12T15:16:11Z")

</div>

One of the example I could think of right now is if i want to collect a hypothesis statement relating to 2 constructs. Lets call them X and Y.

So my search will be: “Hypothesis” and “X” and “Y” (or regex equivalent of this search)

As all academic paper will contain “Hypothesis”, the current global results will return Note that contain X and Y

The current feature requests will give me a list of block ID for those Hypotheses.

Then I can use the “copy search results” function or the Text {expander} plugin to show all these results as embeds.

From this, i can see how many studies have explored direct effects, how many have explored conditional/mediating effect…

Or can you help clarify how I can explain clearer?

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 3:17pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/15 "2020-12-12T15:17:11Z")

</div>

@GreenChocho

> Example: if i got articles on “Team Diversity”, which have argument on team dynamics and team cognition.  
> But i want to find causal arguments on the relationship between “Team Diversity” and “team cognition” only, then the current global search function will not be able to help. I need to use the workaround specified in the 1st post.

How does block search make this easier than Global search?

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 3:23pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/16 "2020-12-12T15:23:53Z")

</div>

Currently, Global search will not return the block/line results if you only search by keywords.

If you use the regex in the 1st post, then global search will return the block level results.  
BUT you will have to click the “…and xx more matches” in each note to see the block.  
Then you will need to manually create an embed (or use the WorkBench plugin) to send it back to your current working note.

IF this feature request is implemented. Then i can just use the copy search results function or Text Expander to gather all this block (block only, not FULL note) inside my current working note.

---

<div class="post-metadata">

**Author:** ![malecjan](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@malecjan](https://forum.obsidian.md/u/malecjan)\
**Post date:** [December 12, 2020, 3:25pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/17 "2020-12-12T15:25:04Z")

</div>

Possible operator:

- scope:line
- scope:innermost-block // useful when [nested blocks](https://forum.obsidian.md/t/support-sub-list-block-id-linking/9151) are recognized
- scope:block
- scope:innermost-chapter
- scope:h6-chapter
- …
- scope:h1-chapter
- scope:chapter
- scope:file // this is default now

Restricting scope at higher levels is already done by “path” and “file” operators:

- path:“folder1/folder2” // restricts search to content of relative path like search in Windows File Explorer.
- path:"/folder1/folder2/file3.md" // like above but restricted to one file
- file:“file3.md”

But that is rather in another sense, matched terms still have to occur within the same file so “scope:file” is currently the upper limit for the scope.

Reference: [https://publish.obsidian.md/help/Plugins/Search](https://publish.obsidian.md/help/Plugins/Search)

Ability to nest “scope” operator in groups is desirable.  
For example: “`(term1 term2 scope:line) term3`” to match line with term1 and term2 only in the files which contain also term3 anywhere.

`scope:line` would work also for table rows (like database records, although not distinguishing fields/columns)

EDIT: Partial implementation is now promissed in posts [#30](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/30) and [#33](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/33).

* * *

Another helpful behavior in this pursuit would be option to rank/sort search results based on closeness of keywords in the match.

---

<div class="post-metadata">

**Author:** ![Klaas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.obsidian.md/u/Klaas)\
**Post date:** [December 12, 2020, 3:29pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/18 "2020-12-12T15:29:24Z")

</div>

@GreenChocho: OK, got it. The last paragraph makes the advantage of this FR clear.  
Thank you, kind sir.

---

<div class="post-metadata">

**Author:** ![GreenChocho](https://forum.obsidian.md/user_avatar/forum.obsidian.md/greenchocho/32/4942_2.png) [@GreenChocho](https://forum.obsidian.md/u/GreenChocho)\
**Post date:** [December 12, 2020, 3:30pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/19 "2020-12-12T15:30:10Z")

</div>

I also enjoyed the discussion 😃

---

<div class="post-metadata">

**Author:** ![octavius](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@octavius](https://forum.obsidian.md/u/octavius)\
**Post date:** [December 12, 2020, 7:06pm UTC](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621/20 "2020-12-12T19:06:51Z")

</div>

My apologize if my tone sounds offensive. I didn’t mean it. Acturally I am so grateful that Obsidian team let me use such a great app for free. Also thanks for your advice.

`tag:#idea -#done` cannot filter the `1. balabala #idea`, this is because the search is based on whole file not a block or a paragraph. So `tag:#idea -#done` give desired result.

You could try it by creating a demo.md file and copy paste these two paragraphs to the file, then search by `tag:#idea -#done`, you will find that the demo.md doesn’t appear on the result.

[Next page](https://forum.obsidian.md/t/global-search-for-blocks-with-multiple-keywords/7621.md?page=2)
