How can I put buttons after the note label. The button/icon could be used for displaying a status like online/offlien or something like that. thanks
{
"data" : {
"title" : "Main",
"attr" : { "href" : "#link" },
"icon" : "module"
}
}
in css
.jstree .module {
background: url(../extensions.png) no-repeat top left !important;
}
Related
I have an existing Gatsby/Prismic blog. I'm trying now to organize my content by using categories. Does anyone knows a good tutorial? Theres literally just 1 Documentation that Ive found and its not really helping. Does anyone knows the steps to create and display Categories using Gatsby and Prismic?
In "Prismic" add a new "Content Type" that is of "Repeatable Type" called "category".
To build the category structure you can use "Build Mode" or "JSON editor" on the right side. If you choose "JSON editor"
paste in .
{
"Main" : {
"name" : {
"type" : "Text",
"config" : {
"label" : "name",
"placeholder" : "Name of the category"
}
}
}
}
...and save.
Now add new categories like you do new blog posts. Click new content and then "category" and input a category name ex: events then press "save" and "publish".
Now edit your blog post content base. If you click on the JSON editor add to the Meta
{
"Main" : {
//Here is your code for the blog post add the Meta below
"Meta" : {
"categories" : {
"type" : "Group",
"config" : {
"fields" : {
"category" : {
"type" : "Link",
"config" : {
"select" : "document",
"customtypes" : [ "category" ],
"label" : "category",
"placeholder" : "Category"
}
}
},
"label" : "Categories"
}
}
}
}
Click on your old blog posts that you want to add the category too. There should now be a Meta tag next to the Main. When you click it you will see that there is a category field which when clicked list the category fields you made. Select one.
Now you can filter your blog posts by categories. How you do this is up to you, perhaps a query to get all the the category names which you put into a drop down?
A good example is this Gatsby Starter https://github.com/LekoArts/gatsby-starter-prismic-i18n
Is it possible to create an initial script for Elasticsearch?
For example, I prepare one JSON file with index 20 users and 20 books.
I want to load it by the single request.
Example file:
PUT eyes
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"_doc" : {
"properties" : {
"name" : { "type" : "text" },
"color" : { "type" : "text" }
}
}
}
}
PUT eyes/_doc/1
{
"name": "XXX"
"color" : "red"
}
PUT eyes/_doc/2
{
"name": "XXXX"
"color" : "blue"
}
You can use bulk API for populating your index in one single call.
https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html
PUT /eyes/_doc/_bulk
{"index":{"_id":1}}
{"name":"XXX","color":"red"}
{"index":{"_id":2}}
{"name":"XXX","color":"blue"}
{"index":{"_id":3}}
{"name":"XXX","color":"green"}
I want to customize the response of a hypermedia Rest JPA entity and want to remove all the _links attributes and self link attributes.
My client application is not that big and it knows what exact REST API's to call. So I feel these extra bytes travelling in HTTP packet would always be a over head in my application.
So how can I achieve to remove this links attributes from the response?
Right now REST API response is:
{
"_embedded" : {
"questionsTypes" : [ {
"queTypeID" : 2,
"queDescription" : "Single choice rating selection",
"_links" : {
"self" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType/2"
},
"questionsType" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType/2{?projection}",
"templated" : true
}
}
},{
"queTypeID" : 5,
"queDescription" : "Subjective questions",
"_links" : {
"self" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType/5"
},
"questionsType" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType/5{?projection}",
"templated" : true
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType"
},
"profile" : {
"href" : "http://localhost:8080/question_web/rest/profile/QuestionsType"
},
"search" : {
"href" : "http://localhost:8080/question_web/rest/QuestionsType/search"
}
}
}
Final response I expect, is something like this:
{
"_embedded" : {
"questionsTypes" : [ {
"queTypeID" : 2,
"queDescription" : "Single choice rating selection",
},{
"queTypeID" : 5,
"queDescription" : "Subjective questions",
} ]
}
}
#Component
public class MyEntityProcessor implements RepresentationModelProcessor<EntityModel<MyEntity>> {
#Override
public EntityModel<MyEntity> process(EntityModel<MyEntity> model) {
return EntityModel.of(model.getContent());
}
}
I am new to Elasticsearch. I am hoping to get highlighted field in Java client. If I run the following query in Windows prompt:
{
"query": {
"filtered" : {
"query" : {
"term" : {
"title" : "western"
}
},
"filter" : {
"term" : { "year" : 1961 }
}
}
},
"highlight" : {
fields" : {
"title" : {}
}
}
}
I get nice highlighted text as follows:
{
"_index" : "book",
"_type" : "history",
"_id" : "1",
"_score" : 0.095891505,
"_source":{ "title": "All Quiet on the Western great Front", "year": 1961}
"highlight" : {
"title" : [ "All Quiet on the <em>Western</em> great Front dead" ]
}
}
The highlight
"highlight" : {
"title" : [ "All Quiet on the <em>Western</em> great Front dead" ]
}
can be easily converted into a Java Map object, and the "title" property contains the entire text of the matched field, which is really what I want.
However, in Java client, I get highlighted fragments, which puts different segments of highlighted text of the same field into an array of text.
Thanks and regards.
In the Java API the default number of fragments that are returned is 5. So if you only want one fragment to be returned you need to set that.
client.prepareSearch("book")
.setTypes("history")
.addHighlightedField("title")
.setQuery(query)
.setHighlighterFragmentSize(2000)
.setHighlighterNumOfFragments(1);
You may also set the number of fragments to 0 which will display the entire field with highlighting tags. This will also ignore fragment_size.
.setHighlighterNumOfFragments(0)
Here is what I found and I am not sure whether it is the right or best solution. In Java client, use setHighlighterFragmentSize method:
SearchResponse sr = client.prepareSearch("book")
.setTypes("history")
.addHighlightedField("title")
.setQuery(query)
.setHighlighterFragmentSize(2000) //set it larger than the size of the field so that the only one fragment is returned and it contains the entire text of the field.
I really want to hear what experts out there say and choose their reply as the answer.
Regards.
I have something like the following template in my Elasticsearch. I just want certain part of the data returned, so I turn the source off, and explicitly stated store for the fields I want.
{
"template_1" : {
"order" : 20,
"template" : "test*",
"settings" : { },
"mappings" : {
"_default_" : {
"_source" : {
"enabled" : false
}
},
"type_1" : {
"mydata" :
"store" : "yes",
"type" : "string"
}
}
}
}
}
However, when I query the data, I don't get the fields back. The query works, however, if I enable the _source field. I am just starting with Elasticsearch, so I am not quite sure what I am doing wrong. Any help would be appreciated.
Field definitions should be wrapped in properties section of your mapping:
"type_1" : {
"properties": {
"mydata" :
"store" : "yes",
"type" : "string"
}
}
}