-
Run the application : a) Either do --> java -jar path_to_userfeed.jar b) Or if have maven --> mvn spring-boot:run
-
Once done, run a curl command (POST) localhost:8080/setup?userId=1 [This will set the friends (follower) list (2, 3) for this user.]
-
Now, you can create posts for this user, run a curl command (POST) localhost:8080/post a) This requires JSON to be send as requestBody, for example : { "userId" : 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.LocalDateTime; | |
| import java.time.OffsetDateTime; | |
| public class RequestEntry { | |
| private LocalDateTime localDateTime; | |
| public RequestEntry(final LocalDateTime localDateTime) { | |
| localDateTime.toEpochSecond(OffsetDateTime.now().getOffset()); | |
| this.localDateTime = localDateTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.practice.codingblocks; | |
| import java.util.HashMap; | |
| import java.util.HashSet; | |
| public class SlidingWindow { | |
| private static int maximumWindowSum(int[] arr, int k) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Reference: | |
| https://opensourceconnections.com/blog/2013/07/24/understanding-how-cql3-maps-to-cassandras-internal-data-structure-sets-lists-and-maps/ | |
| // Column-Family | |
| ----------------------------------------------------------------------------------------------- | |
| ID Last First Bonus | |
| 1 Doe John 8000 | |
| 2 Smith Jane 4000 | |
| 3 Beck Sam 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Term queries don't analyze the query, just search for the exact term in the inverted index >>>>>>>>> | |
| "query": { | |
| "term": { | |
| "name": "Framework" | |
| } | |
| } | |
| } | |
| GET /product/_search | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add another field | |
| PUT /product/_mapping >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| { | |
| "properties": { | |
| "date": { | |
| "type": "date", | |
| "format": "yyyy-MM-dd" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MATCH == SHOULD | |
| GET /product/_search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| { | |
| "query": { | |
| "match": { | |
| "name": "Spring Title" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Elasticsearch API | |
| https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html | |
| // Typeless API | |
| https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0 | |
| // Mapping >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| PUT /product | |
| { | |
| "mappings": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Mapping | |
| PUT /department >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| { | |
| "mappings": { | |
| "properties": { | |
| "join_field": { | |
| "type": "join", | |
| "relations": { | |
| "department": "employee" | |
| } |