Can I use com.atlassian.confluence.search.v2.lucene.SearcherAction to track user searches?
Asked by Graham Campbell:

I would like to be able to track the searches made by my users across our Confluence instance. Part of this is so that I can help fine-tune our content based on searches that do not return appropriate results.

I've noticed this action in the logging and profiling:

com.atlassian.confluence.search.v2.lucene.SearcherAction

It's currently set to WARN, which I believe is the default.

If I change this to INFO, will it produce information on individual user-submitted searches that I can track - specifically, does it log the search terms that were used to generate the search results?


Answers:
author: Diego
body: Hello there! Graham, this is a quite interesting question.

I went and started a local instance to try this out. First, I tried with the exact action you specified:

com.atlassian.confluence.search.v2.lucene.SearcherAction

I set the log level to ALL just to check what came up when searches were triggered. However, nothing came up in the logs.

Then, I moved to use com.atlassian.confluence.search.v2.lucene and set it to ALL. This time, I got some feedback from the instance. When I searched, this was the type of entry that came up in the logs:

```
2019-03-21 13:26:04,401 DEBUG [http-nio-8090-exec-19] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +(+(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))) +((title:m^2.0 contentBody:m content-name-unstemmed:m))) +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo))
2019-03-21 13:26:04,477 DEBUG [http-nio-8090-exec-19] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 0ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+((title:m^2.0 contentBody:m content-name-unstemmed:m)) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))))
2019-03-21 13:26:04,821 DEBUG [http-nio-8090-exec-4] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+((title:my^2.0 contentBody:my content-name-unstemmed:my)) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))))
2019-03-21 13:26:04,974 DEBUG [http-nio-8090-exec-6] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+(((spanNear([title:my, title:s], 5, false)^2.0 spanNear([contentBody:my, contentBody:s], 5, false))^4.0) title:"my s"^2.0 contentBody:"my s" ((title:my^2.0 contentBody:my content-name-unstemmed:my) (title:s^2.0 contentBody:s content-name-unstemmed:s))) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))))
2019-03-21 13:26:06,160 DEBUG [http-nio-8090-exec-8] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 2ms, Query = +(+(((spanNear([title:my, title:search], 5, false)^2.0 spanNear([contentBody:my, contentBody:search], 5, false))^4.0) title:"my search"^2.0 contentBody:"my search" ((title:my^2.0 contentBody:my content-name-unstemmed:my) (title:search^2.0 contentBody:search content-name-unstemmed:search))) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type)))) +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo))
2019-03-21 13:26:08,891 DEBUG [http-nio-8090-exec-13] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))) +((title:h^2.0 contentBody:h content-name-unstemmed:h)))
2019-03-21 13:26:09,062 DEBUG [http-nio-8090-exec-19] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+((title:here^2.0 contentBody:here content-name-unstemmed:here)) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))))
2019-03-21 13:26:09,165 DEBUG [http-nio-8090-exec-13] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 0ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+((title:h^2.0 contentBody:h content-name-unstemmed:h)) +(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))))
2019-03-21 13:26:10,270 DEBUG [http-nio-8090-exec-4] [search.v2.lucene.SearcherWithTokenAction] internalPerform Query time = 1ms, Query = +((+ConstantScore(container.content.type:attachment container.content.type:comment container.content.type:custom container.content.type:page container.content.type:blogpost) +ConstantScore(type:attachment type:comment)) ConstantScore(type:personalspacedesc type:space type:attachment type:spacedesc type:comment type:custom type:page type:blogpost type:userinfo)) +(+(ConstantScore(type:personalspacedesc type:attachment type:spacedesc type:page type:blogpost type:userinfo) ConstantScore(+type:custom +(contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:answer contentPluginKey:com.atlassian.confluence.plugins.confluence-questions:question contentPluginKey:com.atlassian.confluence.extra.team-calendars:calendar-content-type contentPluginKey:com.atlassian.confluence.extra.team-calendars:space-calendars-view-content-type))) +((title:here^2.0 contentBody:here content-name-unstemmed:here)))
```

Still, Confluence does not have the resources to track user searches. However, we have two Feature suggestions that aim at this:

**[CONFSERVER-34661 \| Record and List the most popular search terms in Confluence](https://jira.atlassian.com/browse/CONFSERVER-34661)**

**[CONFSERVER-28959 \| Logged User Search Queries on Confluence](https://jira.atlassian.com/browse/CONFSERVER-28959)**

Currently, the best course of action would be to Vote and Watch the reports. Voting increases the report visibility and watching will keep you up to date!

Looking forward to your reply!

comments: author: Graham Campbell
body: Hi Diego, thanks for the thorough repsonse, that's really great info. I'll check out the links you've provided to vote and watch - hopefully we'll see something added soon!


author: Diego
body: Thanks for getting back Graham!

If you ever need a hand, just reach out to Community.

See you!


Tags: confluence-server

log

search

server