Skip to content

Conversation

senocak
Copy link

@senocak senocak commented Oct 8, 2025

Since redis-om uses Jedis behind the scenes, there are 2 open pull requests on Jedis repository for a long time to implement listener, I do not think it will be merged very soon. So, implemeted basic listener in each redisearch functionallity to listen the operations

Using in client side is very staight forward;

@Component
public class LoggingCommandListener implements CommandListener {
    private static final Logger log = LoggerFactory.getLogger(LoggingUnifiedJedis.class);

    @Override
    public void searchStarted(String indexName, Query q, FTSearchParams params) {
        try {
            final Field field = q.getClass().getDeclaredField("_queryString");
            field.setAccessible(true);
            String queryString = (String) field.get(q);
            log.info("Command Started: FT.SEARCH '{}' '{}'", indexName, queryString);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            log.error("Command started on index: {} (unable to retrieve query string)", indexName);
        }
    }

    @Override
    public void searchFinished(String indexName, Query q, FTSearchParams params, SearchResult searchResult) {
        try {
            final Field field = q.getClass().getDeclaredField("_queryString");
            field.setAccessible(true);
            String queryString = (String) field.get(q);
            log.info("Command Finished: FT.SEARCH '{}' '{}' - Total result: {} ", indexName, queryString, searchResult.getTotalResults());
        } catch (NoSuchFieldException | IllegalAccessException e) {
            log.error("Command started on index: {} (unable to retrieve query string)", indexName);
        }
    }
}

Copy link

jit-ci bot commented Oct 8, 2025

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@senocak
Copy link
Author

senocak commented Oct 15, 2025

@foogaro Kindly reminder please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant