Comments (1)
@usama-azakaw I'm sure my response comes too late for your needs, but I'll answer for the community.
I see two approaches depending on what your desired outcome is exactly. One approach is to require all documents in the entire job to be within 2 years of a given date. Another approach is require all documents for each hop to be within 2 years of a given date, which could chain over multiple hops to return results that go well beyond 2 years.
Here's an example of the two approaches.
Create the index
PUT date-example
{
"mappings": {
"properties": {
"@timestamp": {
"type": "date",
"format": "yyyy-MM-dd"
},
"id": {
"type": "keyword"
}
}
}
}
Index some documents - Each document has a different year. The first and last documents are more than 10 years apart from the rest, and won't match any resolution jobs.
POST date-example/_bulk?refresh
{"index": {"_id": "1" }}
{"@timestamp": "2000-01-01", "id": "foo"}
{"index": {"_id": "2" }}
{"@timestamp": "2013-01-01", "id": "foo"}
{"index": {"_id": "3" }}
{"@timestamp": "2014-01-01", "id": "foo"}
{"index": {"_id": "4" }}
{"@timestamp": "2015-01-01", "id": "foo"}
{"index": {"_id": "5" }}
{"@timestamp": "2016-01-01", "id": "foo"}
{"index": {"_id": "6" }}
{"@timestamp": "2017-01-01", "id": "foo"}
{"index": {"_id": "7" }}
{"@timestamp": "2018-01-01", "id": "foo"}
{"index": {"_id": "8" }}
{"@timestamp": "2019-01-01", "id": "foo"}
{"index": {"_id": "9" }}
{"@timestamp": "2030-01-01", "id": "foo"}
Create the entity model - This example borrows from the tutorial on date attributes.
PUT _zentity/models/date-example
{
"attributes": {
"timestamp": {
"type": "date"
},
"id": {
"type": "string"
}
},
"resolvers": {
"timestamp_id": {
"attributes": [ "timestamp", "id" ]
}
},
"matchers": {
"exact": {
"clause": {
"term": {
"{{ field }}": "{{ value }}"
}
}
},
"time_range": {
"clause": {
"range": {
"{{ field }}": {
"gte": "{{ value }}||-{{ params.window }}",
"lte": "{{ value }}||+{{ params.window }}",
"format": "{{ params.format }}"
}
}
},
"params": {
"format": "yyyy-MM-dd",
"window": "2y"
}
}
},
"indices": {
"date-example": {
"fields": {
"@timestamp": {
"attribute": "timestamp",
"matcher": "time_range"
},
"id": {
"attribute": "id",
"matcher": "exact"
}
}
}
}
}
Resolve an entity - This example uses the "scope
field to requires all documents in the job to be within two years of the given date.
Request:
POST _zentity/resolution/date-example?_source=false&queries
{
"attributes": {
"id": [ "foo" ],
"timestamp": [ "2018-01-01" ]
},
"scope": {
"include": {
"attributes": {
"timestamp": [ "2018-01-01" ]
}
}
}
}
Response:
{
"took" : 3,
"hits" : {
"total" : 4,
"hits" : [ {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "5",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2016-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "6",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2017-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "7",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2018-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "8",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2019-01-01" ]
}
} ]
}
}
Resolve an entity - This example requires all documents in each hop to be within two years of the given date. This will return all documents except the ones whose years are more than 10 years apart from the rest of the documents.
Request:
POST _zentity/resolution/date-example?_source=false&queries
{
"attributes": {
"id": [ "foo" ],
"timestamp": [ "2018-01-01" ]
}
}
Response:
{
"took" : 6,
"hits" : {
"total" : 7,
"hits" : [ {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "5",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2016-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "6",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2017-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "7",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2018-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "8",
"_hop" : 0,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2019-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "3",
"_hop" : 1,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2014-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "4",
"_hop" : 1,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2015-01-01" ]
}
}, {
"_index" : "date-example",
"_type" : "_doc",
"_id" : "2",
"_hop" : 2,
"_query" : 0,
"_attributes" : {
"id" : [ "foo" ],
"timestamp" : [ "2013-01-01" ]
}
} ]
}
}
from zentity.
Related Issues (20)
- [Bug] HOT 2
- Support for ElasticSearch 8.X HOT 12
- support recent patch versions for ES 7.17.x HOT 1
- Non-Lating Language Support
- Zentity not honoring nesting HOT 6
- Release Plan: 1.6.2 HOT 1
- Add logging to zentity
- Use a multi-node cluster in production mode for integration tests HOT 3
- Rename the default branch from "master" to "main" HOT 1
- Allow creation of entity models with empty top-level objects. HOT 2
- Implement and enforce requirements for names of attributes, resolvers, and matchers. HOT 2
- Allow attributes to be represented as nested fields HOT 1
- Release Plan 1.8.0 HOT 2
- Add integration tests for Elasticsearch security features HOT 2
- [Bug] zentity fails to obtain attribute values from object arrays during resolution
- Release Plan: 1.8.1 HOT 1
- OpenSearch support HOT 1
- Releases 7.12.1.jar instead of .zip HOT 1
- Support for Elasticsearch 7.13.x and 7.14.x HOT 1
- Support OpenSearch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zentity.