Aggregation innerAggregation = new Aggregation.Builder()
.terms(t -> t
.field("inner_field")
.size(10)
)
.build();
// Create the outer aggregation and add the inner aggregation to it
Aggregation outerAggregation = new Aggregation.Builder()
.terms(t -> t
.field("outer_field")
.size(5)
)
.aggregations("inner_agg", innerAggregation)
.aggregations("inner_agg2", innerAggregation)
.build();
Sunday, December 1, 2024
Elastic 8 java client aggregations
Friday, July 26, 2024
Ubuntu 24 display problem
I just installed a new Ubuntu 24. When I run file manager, I lack pieces of the display like text and icons. Most of them appear with a mouse over.
A work around is to select the x.org x server as shown below. But once you do that, you cannot suspend Ubuntu anymore
Note: after doing the instruction here below, I got back my correct display (but still cannot awake successfully after suspend)
sudo apt-get update
sudo dpkg --configure -a
sudo apt-get install update-manager-core
Friday, May 24, 2024
IntelliJ
- to edit a file in column mode
- right click and select "column mode"
- to manage JVMs
- File / Project Structure
- Platform Settings
- or right click on any library in the project "External Libraries" section and then "Open Libraru Settings"
Sunday, January 21, 2024
Python string format / print
a) using str.format():
>>> print('We are the {} who say "{}!"'.format('knights', 'Ni'))
We are the knights who say "Ni!"
The brackets and characters within them (called format fields) are replaced with the objects passed into the str.format() method. A number in the brackets refers to the position of the object passed into the str.format() method.
>>> print('{1} and {0}'.format('spam', 'eggs'))
eggs and spam
>>> print('This {food} is {adjective}.'.format(food='jam', adjective='absolutely horrible'))
This spam is absolutely horrible.
Positional and keyword arguments can be arbitrarily combined:
>>> print('The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred', other='Georg'))
The story of Bill, Manfred, and Georg.
b) using f-strings (need Python 3.6)
toto = 10
titi = 15
titi = 15
print(f' toto = {toto}', f' titi = {titi}')
print() can take 255 parameters. When using '+' is a way to have a single parameter is used.
print() can take 255 parameters. When using '+' is a way to have a single parameter is used.
c) using % format (old school, strong limitations)
_________________ from copilot about f-string versus format print
Both f-strings and the `format()` method in Python are used for string formatting, but they have some differences.
f-strings (formatted string literals) were introduced in Python 3.6. They are prefixed with 'f' and are a new and improved way to format strings in Python. They are concise, easy to read, and less prone to error than other formatting methods.
The `format()` method is available in both Python 2 and 3. It's more verbose than f-strings, but it's more flexible and can do a few things that f-strings can't, like dynamic formatting. Here's an example:
>>> percentage = 0.23456789
>>> '{:2.2%}'.format(percentage)
'23.46%'
In general, if you're using Python 3.6 or later, f-strings are the recommended way to format strings due to their simplicity and efficiency. However, if you need to support older versions of Python or require more complex formatting, you might want to use the `format()` method.
print" is a function in Python3 (was a statement in Python2)
def print(self, *args, sep=' ', end='\n', file=None)
.
Monday, January 15, 2024
Jupyter notebook
- start
- "jupyter notebook"
- from ~/tools/jupyter. (to be able to retrieve jupyter projects)
Monday, December 4, 2023
vscode
- select a column
- click once on the top position
- alt + shift + keep left click mouse to select a colum
- disable autocompletion in txt files
- ~/Library/Application Support/Code/User/settings.json
"[plaintext]": {
"editor.suggest.showSnippets": false,
"editor.suggest.showWords": false,
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.acceptSuggestionOnEnter": "off"
}
Tuesday, November 21, 2023
codium editor
Codium is like "VS Code" but without Microsoft prorpietary parts.
- select a rectangle on MacOS:
- set the cursor on the line
- keep pressed "alt ⌥" + "cmd ⌘" and use the down arrows
- edit
Subscribe to:
Posts (Atom)