Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add treatWordAsLuceneQuery to wordsSocialVolume #4402

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Sep 30, 2024

Changes

Add a boolean parameter named treatWordAsLuceneQuery to the wordsSocialVolume GraphQL query.
If the parameter is set to true, the words are passed to metricshub as they are, so eth AND nft becomes a valid input.
If the parameter is set to false, the words are lowercased before being sent. This was required because otherwise words that are valid Lucene keywords broke the query. For example, the ticker of notcoin is NOT, which is also a keyword, so it needed to be lowercased otherwise it caused a syntax error.
Defaults to false.

If a query like eth OR nft is queried without setting the flag to true, it is interpreted as eth or nft, which matches if any of those words is seen in a message, essentially turning it into eth OR nft OR or

{
  wordsSocialVolume(
    from: "utc_now-2d"
    to: "utc_now"
    interval: "1d"
    selector: {words: ["eth AND nft", "btc"]}
    treatWordAsLuceneQuery: true
  ) {
      word
      timeseriesData {
        mentionsCount
        datetime
      }
  }
}
{
  "data": {
    "wordsSocialVolume": [
      {
        "timeseriesData": [
          {
            "datetime": "2024-09-28T00:00:00Z",
            "mentionsCount": 420
          },
          {
            "datetime": "2024-09-29T00:00:00Z",
            "mentionsCount": 487
          },
          {
            "datetime": "2024-09-30T00:00:00Z",
            "mentionsCount": 281
          }
        ],
        "word": "btc"
      },
      {
        "timeseriesData": [
          {
            "datetime": "2024-09-28T00:00:00Z",
            "mentionsCount": 1
          },
          {
            "datetime": "2024-09-29T00:00:00Z",
            "mentionsCount": 2
          },
          {
            "datetime": "2024-09-30T00:00:00Z",
            "mentionsCount": 1
          }
        ],
        "word": "eth AND nft"
      }
    ]
  }
}

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

@tspenov
Copy link
Contributor

tspenov commented Sep 30, 2024

@IvanIvanoff can you add a test

@IvanIvanoff IvanIvanoff merged commit 38b58dc into master Sep 30, 2024
1 of 4 checks passed
@IvanIvanoff IvanIvanoff deleted the words-social-volume-as-lucene branch September 30, 2024 13:48
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.

3 participants