0
votes

I want the different parts of my code to make annotations in my Solr logs so I know which parts of the code are generating which queries.

A log line currently looks like:

INFO: [collection1] webapp=/solr path=/select/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"} hits=0 status=0 QTime=2

I'd prefer if it said something like:

INFO: [collection1] webapp=/solr path=/select/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"} hits=0 status=0 QTime=2 Source=Scraper

INFO: [collection1] webapp=/solr path=/select/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"} hits=0 status=0 QTime=2 Source=user-query

Or something along those lines.

I suppose I could do this by using negation in the query, so every query has something like -source:scraper. That shouldn't affect the query too much (guessing it'd be a negligible performance penalty since I lack a source field), and it'd serve the purpose, but I'm hopeful there's a better way.

1

1 Answers

0
votes

I can see couple of solutions:

  1. Just add extra query parameter that is not used anywhere. Something like:

    &source=Scraper
    &source=user-query
    

    It should end up as:

    INFO: [collection1] webapp=/solr path=/select/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"&source=Scraper} hits=0 status=0 QTime=2
    
    INFO: [collection1] webapp=/solr path=/select/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"&source=user-query} hits=0 status=0 QTime=2
    

    (I does not look very nice but you can filter filter what you need from logs)

  2. Set up different query handlers, one for Scraper and another one for user-query. Then your logs will look something like that:

    INFO: [collection1] webapp=/solr path=/scraper/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"} hits=0 status=0 QTime=2
    
    INFO: [collection1] webapp=/solr path=/user-query/ params={fq=dateFiled:[2007-01-01T00:00:00Z+TO+2007-12-31T00:00:00Z]&fq=status:Precedential&fq=westCite:"509+F.3d+173"} hits=0 status=0 QTime=2
    
  3. Write very small custom plugin that can try to add extra info to the logs (probably based on info from option 1)

Option 1 and 2 will not have any performance consequences and they are extremely easy to implement. Option 3 can cost you a bit of time to implement and execute (probably way less than 1ms per query)