Skip to content

Instantly share code, notes, and snippets.

@royib
royib / filterQueryContext.json
Last active October 28, 2019 08:34
Querying Elasticsearch- filter + query Context
{
"query": {
"bool": {
"must": {
Leaf query clauses - affects the scoring of matching documents
},
"must_not" : {
Leaf query clauses - affects the scoring of matching documents
},
"should" : {
@royib
royib / noScore.json
Created October 28, 2019 08:36
Querying Elasticsearch- no score at all
{
"query": {
"bool": {
"filter": [
{
"term": { "gender": "female" }
},
{
"range": { "age": {"gte":"50"} }
}
@royib
royib / termTextQuery.json
Created October 28, 2019 09:14
Querying Elasticsearch- Term-text query
{
"query": {
"term": {
"mail_from": "emma@somemail.com"
}
}
}
@royib
royib / compoundQuery.json
Last active October 28, 2019 09:40
Querying Elasticsearch- Compound query
{
"query": {
"bool": {
"must": {
"match": {
"mail_body": "Jeff BRidges"
}
},
"filter": {
"term": {
@royib
royib / FullTextQuery.json
Last active October 28, 2019 16:34
Querying Elasticsearch- Full-text query
{
"query": {
"match": {
"mail_body": "Jeff BRidges"
}
}
}
import React from "react";
import FormContext from "./FormContext";
class FormField extends React.Component {
async componentDidMount() {
let { name, validators = [] } = this.props;
const { validateField, getFieldValue } = this.context;
// set default value
const newValue = getFieldValue({ name });
import React, { Fragment } from "react";
export default props => {
const {
onChange,
validateField,
value,
error,
name,
validationText,
@royib
royib / clean-nest-entities.ts
Last active January 19, 2022 10:38
clean nest sample application entities layer
export class Author {
firstName: string;
lastName: string;
}
export class Genre {
name: string;
}
@royib
royib / generic-repository-abstract.ts
Created January 19, 2022 11:56
generic repository abstract
export abstract class IGenericRepository<T> {
abstract getAll(): Promise<T[]>;
abstract get(id: string): Promise<T>;
abstract create(item: T): Promise<T>;
abstract update(id: string, item: T);
}
@royib
royib / data-services-abstraction.ts
Created January 19, 2022 11:57
data services abstraction
import { Author, Book, Genre } from '../entities';
import { IGenericRepository } from './generic-repository.abstract';
export abstract class IDataServices {
abstract authors: IGenericRepository<Author>;
abstract books: IGenericRepository<Book>;
abstract genres: IGenericRepository<Genre>;
}