Searching for an item within a specific numerical range on Elastic Search

In the Elastic Search, we have two fields called startid and endid. For example, startid is 3061410 and endid is 3061450. Whenever a number between 3061410 and 3061450 is inputted, the query should retrieve that specific item. To view the elastic index snapshot, please visit this link: Elastic index snapshot

The expected result snapshot can be found by clicking here: Click here

I attempted the following query but unfortunately did not obtain the anticipated outcome:

{ "range": { "startid": { "gte": parseInt(this.selectedOP_no),"lte":+parseInt(this.selectedOP_no)+40 } } }

Here, this.selectedOP_no represents a number within the range of startid and endid, such as 3061411

Answer №1

To effectively utilize the two fields, it is essential to establish two separate conditions, one for each field. This can be achieved through the following structure:

{ 
   "bool": {
      "filter": [
         {
            "range": { 
              "endid": { 
                 "gte": parseInt(this.selectedOP_no) + 40 
              } 
            } 
         },
         {
            "range": { 
              "startid": { 
                 "lte":+parseInt(this.selectedOP_no)
              } 
            } 
         }
      ]
   }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When working with an observable in an Angular Material table, the *ngIf directive may not function as expected

Attempting to utilize an Angular Material table with expandable rows, specifically to display information based on screen width reaching a particular breakpoint. Utilizing an observable isHandSetPortrait$ that is subscribed to in the HTML to determine if t ...

Utilizing NGRX reducers with a common state object

Looking for a solution with two reducers: export function reducer1(state: State = initialState,: Actions1.Actions1); export function reducer2(state: State = initialState,: Actions2.Actions1); What I want is for both reducers to affect the same state objec ...

Attempting to transmit the chosen value, extracted from the selection, into a function, repetitively and multiple times, within an array

I'm attempting to build a dynamic table that allows the user to select the number of rows. Each row contains two dropdown menus with options ranging from 1 to 10. Upon selecting a number from the dropdown, I want it to be passed to a function in the T ...

Using Nestjs to inject providers into new instances of objects created using the "new" keyword

Is it possible to inject a provider into objects created by using the new keyword? For instance: @Injectable() export class SomeService { } export class SomeObject { @Inject() service: SomeService; } let obj = new SomeObject(); When I try this in my t ...

I need help figuring out how to showcase the following object in an Angular 5 HTML file

https://i.sstatic.net/XXm3W.png The console screenshot above shows an object with two values: users and tickers, each being an array of values. How can I display these values in an Angular 5 HTML template similar to the screenshot above? I attempted to ...

Using a jQuery plugin within an Angular 2 component: A step-by-step guide

Looking to implement an image slider plugin called Vegas only on the home page within my Angular 2 application. The Vegas jQuery plugin has been added via npm and is located under the /node_module directory. The following code snippet shows my home page c ...

Building stateless functional components in React using Typescript version 0.14

Demonstration: import * as React from 'react' declare function obtainMarineLife(x: any): any; declare var Tank: any; var OceanicHabitat = ({category}) => ( <Tank> {obtainMarineLife(category)} </Tank> ); let y = <Ocea ...

strange complications with importing TypeScript

In my Typescript projects, I frequently use an npm module called common-types (repository: https://github.com/lifegadget/common-types). Recently, I added an enum for managing Firebase projects named FirebaseEvent. Here is how it is defined: export enum Fi ...

managing commitments in TypeScript

Is there a way to convert a promise into a string, or is there another method for handling this result? I am encountering an error stating "You cannot use an argument of type 'Promise' for a parameter of type 'string'." const pokemonIma ...

The property y is not found on type x during property deconstruction

After creating a straightforward projectname.tsx file to contain my interfaces/types, I encountered an issue: export interface Movie { id: number; title: string; posterPath: string; } In another component, I aimed to utilize the Movie interface to s ...

Angular 9 issue: Unexpected characters are being appended to the route URL when using queryParams

In my application, I have a side navigation bar with icons that link to different routes. One of the icons should lead me to a route with a query parameter. For example- localhost:4200/test?t=1. I defined an interface for my navigation items like this. ex ...

Arrange the angular datatables in a specific order without displaying the usual user interaction triangles

I am looking to arrange the data in a fixed manner without any user interaction for sorting. However, it seems that I can either completely disable ordering like this: this.dtOptions = { paging: false, lengthChange: false, searching: false, orderi ...

Limit pasted content in an Angular contenteditable div

Is there a way to limit the input in a contenteditable div? I am developing my own WYSIWYG editor and want to prevent users from pasting content from external websites and copying styles. I want to achieve the same effect as if the content was pasted into ...

"Enhancing the functionality of @angular/fire by transitioning from version 6.x to 7.x

I need to update my app dependencies and code from @angular/fire 6.x to 7.1.0-rc4 in order to access a feature that is not available in the 7.0.x version. I made the necessary changes in my package.json as follows: "@angular/fire": "~7.1.0-r ...

Is Your IIS Serving Outdated Website Content?

After updating the angular website version on IIS, I am facing an issue where the old version continues to appear in the browser even after stopping the site. How can I ensure that the new version of the website is displayed correctly? I have not implemen ...

Is the slow loading time of the Dev browser due to the large size of the vendor.js file

When using Angular 8.0, my browser takes around 15 seconds to load with ng serve. However, the browser only takes about 4 seconds to load when using ng serve --prod. One of the main reasons for the slow loading time in development is a vendor.js file tha ...

How to transfer files between Dropbox and AWS S3 using Angular 5

Currently, I'm utilizing the Dropbox file picker to download a file. Once a file is selected using the Dropbox picker, I obtain the download link. I'm wondering if it's possible to save it as a bytestream in the browser and then upload it t ...

Tips for implementing a reusable component in Angular 2

Within my module.ts file, @NgModule({ imports: [ BrowserModule, RouterModule.forRoot([ { path: '', component:AppComponent}, { path: 'login', component:AppComponent} ]) ], declarations: [ AppComponent,Mainapp ...

Is it possible to downgrade the AngularCLI version from 1.0.0-beta.30 to 1.0.0-beta.26 on a global scale?

Following the execution of the commands below: npm uninstall -g angular-cli @angular/cli npm cache clean npm install -g <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2849464f5d44495a054b4441681906180618054a4d5c49061a1e">[e ...

Taking advantage of Input decorator to access several properties in Angular 2

I am currently working on a component that is designed to receive two inputs through its selector. However, I would like to make it flexible enough to accept any number of inputs from various components. Initially, I tried using a single @Input() decorator ...