Using "block:" in a query

Things I have tried

I have searched google and the online help; if the answer is there, I cannot find it. I have read the documentation but remain stymied.

I want to have a query block in a page that collects & displays blocks from other pages that match a search criterion.

What I’m trying to do

I have list items or tasks in various files. Some of these are tagged xxx, others are tagged yyy, and a few are tagged with both xxx and yyy. I want to extract only those list items or tasks both both tags.

I started with this:

```query
tag:#xxx tag:#yyy
```

This shows contents of files that contain both tags, which makes sense.
However, I only want the blocks that match.

So I tried:

```query
block:(tag:#xxx tag:#yyy)
```

But this yields no results at all.

What am I missing?

Hard to test without good test data, per se, but what about…

```query
block:("#xxx" “#yyy”)
```

Aside: what a great way to show code blocks in Discourse! Thanks for that!

Ok; that works, and I can live with it, even though it was slower than I thought it would be.

The doc advises to use the tags: keyword because "This is faster and more accurate than searching for the tag in plaintext #work, as it uses the cached information and ignores text in code blocks and sections that aren't markdown text."

So I’m kind of curious why my query didn’t work.

Still, I’m marking this solved. Thanks!

I don’t think the tags part of the search engine is engineered to work within other kinds of queries. Maybe someday!

Ah, well, that’s that then. Thanks for the information and the workaround.

1 Like

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