Knowledge Management

Is there any way to limit the number of search results in a data model?

emiliavanderwer
Explorer

When searching on an index, you can pipe to "head 100" and retrieve 100 results.

index=my_index cookie* | head 100

However, when searching over a data model, how do you tell it to get only 100 results?

| tstats count from datamodel=my_dm where g.message=cookie* by g.id

0 Karma
1 Solution

renjith_nair
Legend

@emiliavanderwerf,

Did you try

| tstats count from datamodel=my_dm where g.message=cookie* by g.id|head 100

Below works for me

|tstats count from datamodel=test by sourcetype|head 2

Where test is index=_internal

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

woodcock
Esteemed Legend

The exact same way:

| tstats count from datamodel=my_dm where g.message=cookie* by g.id | head 100

Or, more productively,

| tstats count from datamodel=my_dm where g.message=cookie* by g.id | sort 100 - count

renjith_nair
Legend

@emiliavanderwerf,

Did you try

| tstats count from datamodel=my_dm where g.message=cookie* by g.id|head 100

Below works for me

|tstats count from datamodel=test by sourcetype|head 2

Where test is index=_internal

---
What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...