# Using Content Selectors to Filter Browse View

**URL:** <https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549>\
**Category:** Sonatype Nexus Repository\
**Created:** [September 23, 2019, 3:53pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549 "2019-09-23T15:53:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjq](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/kjq/32/855_2.png) [@kjq](https://community.sonatype.com/u/kjq)\
**Post date:** [September 23, 2019, 3:53pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/1 "2019-09-23T15:53:12Z")

</div>

I am trying to setup content selectors to filter the “browseable” view. I have followed these steps from SO ([nexus3 - Nexus 3 and Content Selectors - Stack Overflow](https://stackoverflow.com/questions/52249328/nexus-3-and-content-selectors)) but when I log in as the user the browse view is completely empty. Search-Read appears to work fine though.

I am not using the anonymous user and have created a different user with the permissions, privileges, roles, etc. The content selector itself looks to work when I preview it.

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [September 23, 2019, 5:12pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/2 "2019-09-23T17:12:55Z")

</div>

I’m guessing that your content selectors need to be modified to allow browsing of directory listings.

This article was written for Nexus Repo 2, but since Repo 3 also uses path based privileges the principles apply for it also:

> **[Browse storage doesn't work for users with restricted read access (Nexus...](https://support.sonatype.com/hc/en-us/articles/213464568-Browse-storage-doesn-t-work-for-users-with-restricted-read-access-Nexus-Repository-2)**
>
> Nexus Repository 2 officially sunsetted June 30, 2025. Visit my.sonatype.com for archived documentation. Migrate to Sonatype Nexus Repository 3 as soon as possible.
> 
> Problem: 
> You've restricted rea...

---

<div class="post-metadata">

**Author:** ![kjq](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/kjq/32/855_2.png) [@kjq](https://community.sonatype.com/u/kjq)\
**Post date:** [September 23, 2019, 5:45pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/3 "2019-09-23T17:45:31Z")

</div>

Makes sense but I am confused where I should apply that.

This is what my content selector looks like now:

(path =^ “.\*/”) and  
(format==“maven2” and coordinate.groupId=^ “my.package”) or  
(format==“npm” and path =^ “@my/package”) or  
(format==“nuget” and path =^ “My.Package”) or  
(format==“pypi” and path =^ “packages/my-package”)

Should I be applying this in the content selector or is this a different privilege (wildcard)? The above does not work for me if it is correct.

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [September 24, 2019, 6:46pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/4 "2019-09-24T18:46:35Z")

</div>

You’ll need to use this:

```auto
(path =~ “.*/”) and

```

Instead of this:

```auto
(path =^ “.*/”) and

```

The first one does a regular expression match, the second one does a “starts with” match.

For the other ones, you’ll want to change them to use regular expressions with path based matching, and also start the paths with “/”, as in:

format==“maven2” and path=~ “/my/package/.\*”

Also note that there is a problem with pypi… it uses POST requests for component uploads.

This means that it will not be possible to restrict pypi deployments using content selectors as they currently exist, since there is no path for them to work against.

We have an issue in our backlog to address this, but it has not yet been scheduled:

> **[What Happened To issues.sonatype.org?](https://central.sonatype.org/faq/what-happened-to-issues-sonatype-org/)**

---

<div class="post-metadata">

**Author:** ![kjq](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/kjq/32/855_2.png) [@kjq](https://community.sonatype.com/u/kjq)\
**Post date:** [September 25, 2019, 12:13pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/5 "2019-09-25T12:13:17Z")

</div>

Thanks so much for the help. It seems to be getting closer…I could only get the results back when I switched or’d the first regex.

(path =~ “._/") or  
(format==“maven2” and path =~ "^/my/package._”) or  
(format==“npm” and path =~ “^/@my/package._") or  
(format==“nuget” and path =~ "^/My.Package._”) or  
(format==“pypi” and path =~ “^/packages/my-package.\*”)

Will return the whole view of the repository but only what is specified in the selector can be accessed it seems. Functionally, this works for me.

I am apply this selector against my “public” (grouped repositories). I was under the impression is would provide a filtered view of that repository? and not the whole thing with limited access?

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [September 25, 2019, 2:15pm UTC](https://community.sonatype.com/t/using-content-selectors-to-filter-browse-view/2549/6 "2019-09-25T14:15:36Z")

</div>

> I am apply this selector against my “public” (grouped repositories). I was under the impression is would provide a filtered view of that repository? and not the whole thing with limited access?

This gives access to all directory listings, so everything will be visible:

```auto
(path =~ “./")

```

You’d need something like this to restrict viewing to a specific path:

```auto
 /|/com/|/com/mycompany/|/com/mycompany/team-a/.* 

```
