MongoDB full text inconsistent results - mongodb

I'm going deep into full-text search features and i'm finding some strange behaviors I cannot explain.
Here is a simple batch I run to setup my db for the test.
use MusicDB
db.songs.insertMany([{
"rank": 1000,
"authors": ["Pink Floyd"],
"title": [
{ "language": "en", "text": "Comfortably numb" },
{ "language": "it", "text": "Piacevolmente insensibile" }
],
"text": [
{ "language": "en", "text": "Hello, Is there anybody in there? Just nod if you can hear me Is there anyone at home? Come on now I hear you're feeling down I can ease your pain And get you on your feet again Relax I'll need some information first Just the basic facts Can you show me where it hurts There is no pain, you are receding A distant ship smoke on the horizon You are coming through in waves Your lips move but I can't hear what you're saying When I was a child I had a fever My hands felt just like two balloons Now I've got that feeling once again I can't explain, you would not understand This is now how I am I have become comfortably numb O.K. Just a little pin prick There'll be no more aaaaaaaah! But you may feel a little sick Can you stand up? I do belive it's working, good That'll keep you going through the show Come on it's time to go. There is no pain you are receding A distant ship smoke on the horizon You are only coming through in waves our lips move but I can't hear what you're saying When I was a child I caught a fleeting glimpse Out of the corner of my eye I turned to look but it was gone I cannot put my finger on it now The child is grown The dream is gone And I have become Comfortably numb."},
{ "language": "it", "text": "Coraggio, lo so che ti senti triste. Posso alleviare il tuo dolore e rimetterti di nuovo in piedi. Rilassati. Prima di tutto ho bisogno di sapere senza troppi dettagli dove ti fa male. Il dolore è sparito, stai guarendo Il fumo di una nave lontana all'orizzonte stai risalendo onda dopo onda. Le tue labbra si muovono, ma io non riesco a sentire quello che stai dicendo. Da bambino ho avuto la febbre, le mie mani erano gonfie come palloni. Adesso avverto di nuovo quella senzazione, non riesco a spiegartelo, non riusciresti a capire. Questo non sono io. Sto diventando piacevolmente insensibile. Va bene, solo una punturina, e non piangerai più. Ma può darsi che avrai un po' di nausea, Ce la fai a stare in piedi? Penso che stia funzionando, bene. Questo ti terrà in piedi per tutto lo spettacolo. Dai, è ora di andare. Il dolore è sparito, si sta allontanando. Il fumo di una nave lontana all'orizzonte Stai risalendo onda dopo onda. Le tue labbra si muovono, ma io non riesco a sentire quello che stai dicendo. Da bambino colsi con la coda dell'occhio un rapido movimento. Mi girai a guardare, ma era sparito, non riescii a capire cosa fosse, adesso il bambino è cresciuto, il sogno è finito. e io sono diventato piacevolmente insensibile."}
]
},
{
"rank": 999,
"authors": ["Led Zeppelin"],
"title": [
{ "language": "en", "text": "Stairway to Heaven" },
{ "language": "it", "text": "Scalinata per il paradiso" }
],
"text": [
{ "language": "en", "text": "There's a lady who's sure all that glitters is gold And she's buying a stairway to heaven. When she gets there she knows, if the stores are all closed With a word she can get what she came for. Ooh, ooh, and she's buying a stairway to heaven. There's a sign on the wall but she wants to be sure 'Cause you know sometimes words have two meanings. In a tree by the brook, there's a songbird who sings, Sometimes all of our thoughts are misgiven. Ooh, it makes me wonder, Ooh, it makes me wonder. There's a feeling I get when I look to the west, And my spirit is crying for leaving. In my thoughts I have seen rings of smoke through the trees, And the voices of those who standing looking. Ooh, it makes me wonder,Ooh, it really makes me wonder. And it's whispered that soon if we all call the tune Then the piper will lead us to reason. And a new day will dawn for those who stand long And the forests will echo with laughter. If there's a bustle in your hedgerow, don't be alarmed now, It's just a spring clean for the May queen. Yes, there are two paths you can go by, but in the long run There's still time to change the road you're on. And it makes me wonder. Your head is humming and it won't go, in case you don't know, The piper's calling you to join him, Dear lady, can you hear the wind blow, and did you know Your stairway lies on the whispering wind. And as we wind on down the road Our shadows taller than our soul. There walks a lady we all know Who shines white light and wants to show How ev'rything still turns to gold. And if you listen very hard The tune will come to you at last. When all are one and one is all To be a rock and not to roll. And she's buying a stairway to Heaven."},
{ "language": "it", "text": "C'è una donna che crede che tutto cio che luccica sia oro Ha intenzione di comprare una scala per raggiungere il Paradiso E quando vi arriva sa, se i negozi sono chiusi, con una parola può avere ciò per cui è venuta qui Ooh, ooh, e sta comprando una scala per il paradiso. C'è una scritta sul muro, ma lei vuole essere sicura Perchè, lo sai, a volte le parole hanni due significati Su un albero vicino al ponte, c'è un uccellino che canta A volte, tutti i nostri pensieri sono sospetti. Ooh, e mi domando, Ooh, e mi domando. Quella sensazione che provo quando guardo verso Ovest E la mia anima grida di partire Nei miei pensieri ho visto spirali di fumo tra gli alberi. E le voci di quelli che stanno a guardare Ooh, e mi fa pensare, Ooh, e mi fa pensare. E si mormora che presto, se tutti canteremo la melodia il pifferaio ci guiderà alla ragione e un nuovo giorno spunterà per quelli che stavano aspettando da tanto E le foreste eccheggeranno di risate. Se c'è una via vai sul tuo sentiero, non ti allarmare Sono solo i preparativi per la reginetta di Maggio Si, ci sono due strade che puoi percorrere, ma alla fine farai ancora tempo a cambiare il tuo percorso. E mi fa pensare La tua testa canitcchia e quella melodia non se ne andrà, nel caso non lo sapessi, Il pifferaio ti sta chiamando, vuole che tu vada da lui. Dolce donna, senti il vento soffiare e lo sapevi che la tua scala poggia sui sussurri del vento. E mentre scendiamo lungo la strada e le nostre ombre sono più alte della nostra anima Là cammina una signora che noi tutti conosciamo che fa splendere una luce bianca e vuol mostrarci come tutto continui a tramutarsi in oro. E se ascolti molto attentamente Prima o poi la melodia giungerà a te Quando tutti sono uno e una cosa sola è tutto essere una roccia ma senza rotolare. E sta comprando una scala verso il Paradiso."}
]
}]);
db.songs.createIndex({ "title.text": "text", "text.text": "text" })
Now please notice that the word "lady" appears only one time into the "en" text of the second record. Now I runs the following queries
db.songs.find({ "$text": { "$search": "lady", "$language": "it" }})
// no occurrences found
db.songs.find({ "$text": { "$search": "lady", "$language": "en" }})
// one occurrence found
db.songs.find({ "$text": { "$search": "lady", "$language": "none" }})
// no occurrences found
Unfortunately this does not match the documentation that say "language" field is only_ used for stemming so I figure that all the searches should return exactly one document.
"$search": "lady" with "$language": "en"
// "lady" is stemmed to "ladi" so this match "lady" and "ladies"
"$search": "lady" with "$language": "it"
// "lady" is stemmed exactly to "lady" so this match "lady"
"$search": "lady" with "$language": "none"
// "lady" is not stemmed but tokenization results in "lady" so this match "lady"
Can someone explain if I'm going wrong in creating the index of in reading the results?
Thanks.

Related

Como escolher o banco da sua workspace no Oracle APEX? [closed]

Closed. This question is not written in English. It is not currently accepting answers.
Stack Overflow is an English-only site. The author must be able to communicate in English to understand and engage with any comments and/or answers their question receives. Don't translate this post for the author; machine translations can be inaccurate, and even human translations can alter the intended meaning of the post.
Closed 18 hours ago.
Improve this question
Olá , estou entrando recentemente no ramo de desenvolvedor , então alguns termos possam parecer confusos dentro da minha pergunta, pois estou aprendendo de forma autodidata.
Estou tentando criar uma base do Oracle APEX para meus estudos , e dentro do OracleXE, tenho duas Oracle connections Ilustração dos dois DB, Eu consegui criar a base APEX pela base SYS Dentro da Base APEX, mas queria criar com a base HR. Porque dentro da HR tenho as tabelas que criei para estudo com dados, e queria usa-las dentro do APEX , teria como mudar pra essa outra base? se não , como faço pra usar a base HR dentro do APEX?.
desde já agradeço por tentar me ajudar de qualquer forma.
Att.
Yuri Bertuzzi.
Criar uma base APEX para estudos , esperava conseguir usar a DB HR , mas apenas consegui pela SYS

WhatsApp Templates and Error 63016 triggering a lot -- are new lines a problem?

I am using some WhatsApp templates associated with my number. But I am having mixed success in getting them to work without Error 63016. I create 9 templates, and 8 of them are getting the Error, which means that they are not matching the message I am sending with the template.
They do not work either if I execute them through Flow, or through Python (Rest API).
I have tried deleting and re-submitting the same template, and it failed again.
This is bothering me because testing out 9 templates and re-submitting them is laborsome.
Any ideas what m
Template #1, works fine:
Olá {{1}},
Nós vamos novamente te fazer algumas perguntas sobre seus hábitos de
consumo de notícias nas últimas semanas
São poucas perguntas, e as respostas são simples, como “Sim” ou “Não”.
Não deve levar mais de 2 minutos do seu tempo para responder à todas
as perguntas.
Quando estiver pronto para responder, mande qualquer mensagem nessa
conversa, como “Estou pronto”, ou clique no botão abaixo.
Template #2, not working:
Olá {{1}},
Nós vamos te fazer algumas perguntas sobre alguns fatos políticos que
aconteceram nas últimas semanas.
São poucas perguntas, e as respostas são simples, como “Sim” ou “Não”.
Não deve levar mais de 2 minutos do seu tempo para responder à todas
as perguntas.
Quando estiver pronto para responder, mande qualquer mensagem nesse
chat, como “Estou pronto”, ou clique no botão abaixo.

Use of wildcards in Microsoft word to selected text or numbers between round brackets or before a dot

Hi I am a complete novice with Microsoft word wildcard function using ctrl h.
So I need some assistance in selecting all sequence text or numbers between round brackets or before a dot, (including the brackets and dots)
.
More specifically I need to select at once,
all sequence Art.227. -, Art.228. -... or
all sequence (1),(2),(3)... or
all sequence a),b),c) or
all sequence 1.,2.,3., or
all sequence (i),(ii),(iii),
which are bolded in the text, as in the following sample:
Art. 227. -
(1) Banca Naţională a României are competenţa de a aplica sancţiuni administrative, în cazurile în care constată că entităţile prevăzute la art. 223 alin. (1) şi/sau oricare dintre persoanele care exercită responsabilităţi de administrare şi/sau conducere a activităţii de prestare de servicii de plată în cadrul acestora se fac vinovate de următoarele fapte:
a) încălcarea prevederilor art. 150-165, art. 218-221, art. 248 alin. (3), a reglementărilor emise în aplicarea acestor articole, precum şi a actelor delegate adoptate de Comisia Europeană în materie de servicii de plată;
(i) respectarea imediată a clauzelor contractuale care au fost încălcate;
(ii) dispunerea încetării încasării, respectiv restituirea sumelor încasate fără temei legal, într-un termen de cel mult 15 zile calendaristice de la data luării la cunoştinţă a procesului-verbal de constatare a contravenţiei;
(iii) aducerea contractului sau tuturor contractelor, după caz, potrivit prevederilor legale, în termen de cel mult 15 zile calendaristice de la data luării la cunoştinţă a procesului-verbal de constatare a contravenţiei;
b) nerespectarea măsurilor administrative dispuse potrivit art. 223 alin. (2) lit. c).
1. acceptarea operaţiunilor de plată - serviciu de plată prin care un prestator de servicii de plată, în baza unui contract încheiat cu beneficiarul plăţii, acceptă şi prelucrează operaţiuni de plată în scopul transferării fondurilor către beneficiarul plăţii;
2. agent - persoană fizică sau juridică care furnizează servicii de plată în numele şi pe seama unei instituţii de plată sau unui furnizor specializat în servicii de informare cu privire la conturi;
3. autentificare - procedură care permite prestatorului de servicii de plată să verifice identitatea unui utilizator al serviciilor de plată sau valabilitatea utilizării unui anumit instrument de plată şi care include utilizarea elementelor de securitate personalizate ale utilizatorului;
(2) În cazurile prevăzute la alin. (1), Banca Naţională a României are competenţa de a aplica următoarele sancţiuni administrative:
a) avertisment scris;
b) amendă cuprinsă între 10.000 lei şi 100.000 lei, pentru faptele prevăzute la alin. (1) lit. a) şi b);
c) amendă până la de două ori valoarea profiturilor obţinute sau a pierderilor evitate de către persoana responsabilă, în măsura în care acestea pot fi determinate, aplicabilă prestatorilor de servicii de plată;
d) suspendarea temporară a dreptului prestatorilor de servicii de plată de a presta servicii de plată până la remedierea situaţiei care a determinat suspendarea;
e) suspendarea dreptului de acces la sistemele de plăţi până la remedierea situaţiei care a determinat suspendarea.
(3) Sancţiunile administrative prevăzute la alin. (1) pot fi aplicate concomitent cu dispunerea de măsuri administrative potrivit art. 223 alin. (2) lit. c) sau independent de acestea.
(4) Amenzile încasate se fac venit la bugetul de stat.
(5) Aplicarea sancţiunilor administrative prevăzute la alin. (1) se prescrie în termen de 1 an de la data constatării faptei, dar nu mai mult de 3 ani de la data săvârşirii acesteia.
Art. 228. -
(1) Constatarea faptelor prevăzute la art. 227 alin. (1) se realizează de către reprezentanţi împuterniciţi ai Băncii Naţionale a României pe baza raportărilor făcute potrivit legii ori reglementărilor emise în aplicarea acesteia sau actelor delegate adoptate de Comisia Europeană în materie de servicii de plată sau la solicitarea expresă a Băncii Naţionale a României ori în cursul verificărilor desfăşurate la sediul profesional sau real al entităţilor prevăzute la art. 223 alin. (1) sau la locaţiile acestora ori la sediile/locaţiile furnizorilor externi în cazul externalizării activităţilor, după caz.
(2) Actele prin care sunt aplicate sancţiuni administrative şi sunt dispuse măsuri administrative potrivit prevederilor art. 227 şi reglementărilor emise în aplicarea acestora se emit de către guvernatorul, prim-viceguvernatorul sau viceguvernatorii Băncii Naţionale a României, conform reglementărilor interne, cu excepţia sancţiunilor administrative prevăzute la art. 227 alin. (2) lit. d) şi e), care sunt de competenţa Consiliului de administraţie al Băncii Naţionale a României.
(3) Actele prevăzute la alin. (2) trebuie să cuprindă cel puţin elementele de identificare ale persoanei vinovate, descrierea faptei şi a circumstanţelor efectuării acesteia şi temeiul de drept al dispunerii măsurii administrative sau, după caz, al aplicării sancţiunii administrative.
If this is not possible in word, can you help me with regex expressions in notepad++?
Thank you
If I have understood you well ? Use below code in notepad++ regular expression mode ....
Find:^\(?\w+[.)].*$
Replace with: leave it empty or your desired typing
Update ^\(?(\w{1,3})[.)].*$ is a bit more safe

CSS formatting in Flutter

My app in flutter gets from API Text Html and some have a CSS Style.
But, I don't know how I can handle CSS in Flutter.
My API body example:
{
"id": "165517",
"prova_id": "27863318",
"materia_id": "697",
"tipo": "2",
"pergunta": "Considerando-se a Lei nº 9.394/96, que estabelece as diretrizes e bases da educação nacional, relacione a COLUNA II com a COLUNA I, associando os componentes da Educação Básica aos enunciados correspondentes.<br><br>COLUNA I<br><br><ol class=\"orderedlist\"><li class=\"insertorderedlist2-bold\">Educação Infantil</li><li class=\"insertorderedlist2-bold\">Ensino Fundamental</li><li class=\"insertorderedlist2-bold\">Ensino Médio</li></ol><br>COLUNA II<br><br><table class=\"table-richtext\"><tbody class=\"pcss-165517-12\"><tr><td class=\"pcss-165517-14\">( )</td><td>Possui duração de nove anos, é gratuito na escola pública e inicia-se aos seis anos de idade.</td></tr><tr><td>( )</td><td>A preparação básica para o trabalho e a cidadania do educando, para que continue aprendendo, de modo a ser capaz de se adaptar com flexibilidade a novas condições de ocupação ou aperfeiçoamento posteriores, é uma de suas finalidades.</td></tr><tr><td>( )</td><td>A avaliação é realizada por acompanhamento e registro do desenvolvimento das crianças, sem o objetivo de promoção.</td></tr><tr><td>( )</td><td>Os currículos incluirão, obrigatoriamente,o estudo da língua inglesa e poderão ofertar outras línguas estrangeiras, em caráter optativo.</td></tr><tr><td>( )</td><td>O Ensino Religioso, de matrícula facultativa,é parte integrante da formação básica do cidadão nessa etapa da Educação Básica.</td></tr><tr><td>( ) </td><td>Atendimento à criança deve ser realizado durante, no mínimo, quatro horas diárias para o turno parcial, e durante sete horas para a jornada integral.</td></tr></tbody></table><br>Assinale a sequência correta.",
"materia_desc": "Recursos Multifuncionais",
"texto_id": null,
"texto_assoc": null,
"alts": "[{\"id\": 713826, \"letra\": \"a\", \"conteudo\": \"2 2 1 3 3 1\"}, {\"id\": 713827, \"letra\": \"b\", \"conteudo\": \"1 2 3 2 1 3\"}, {\"id\": 713828, \"letra\": \"c\", \"conteudo\": \"3 2 1 1 3 2\"}, {\"id\": 713829, \"letra\": \"d\", \"conteudo\": \"2 3 1 3 2 1<br>\"}]",
My API results:
Large Space...
I use https://pub.dev/packages/flutter_html, but this pack don't support "CSS Attributes" =(
How is the best way to decode HTML with CSS attributes from API? any idea?
The css part might be parsable with https://pub.dev/packages/csslib.

Query an array of Objects matching word in a string field

After executing a query on a huge ontology using Jena, I exported the results in JSON format in a MongoDB collection named items in a database named galileo.
Now I want to query on the collection to find items by their names (names are in the title field), in particular I want that searching for "Astrolabio", I can retrieve all the objects that contain the word "Astrolabio" in the title field (e.g. "Astrolabio", "Astrolabio Piano" etc...).The objects that interest me are contained in the #graph array.
I tried
db.items.find({"#graph":{$elemMatch:{"title":{$regex: /Astrolabio$/}}}})
but it returns lots of objects that don't contain the searched word too.
I tried also
db.items.find({},{"#graph":{$elemMatch:{"title":{$regex: /Astrolabio$/}}}})
but, as I discovered only after my try, it returns only the first object that match the request.
So what's the correct query for what I'm trying to do?
In order to provide an help, here there is a little slice of the document
{
"_id" : ObjectId("59e07632b5d295462b330c4c"),
"#graph" : [
{
"#id" : "http://minerva.atcult.it/rdf/000000016001",
"#type" : [
"bibo:Book",
"bibo:MultiVolumeBook"
],
"P1053" : [
"1 astrolabe",
"1 astrolabio"
],
"abstract" : [
"This astrolabe presently comprises two tympanums, for latitudes 30° and 33°, the other for latitudes 36° and 42° (corresponding to the regions between Persia and the Black Sea). There is an alidade, a rule, and a rete. The back carries a double shadow square and the zodiacal calendar. The instrument comes with a tooled black leather case (cover missing) containing a sixteenth-century manuscript note stating that the astrolabe was brought from Spain and dates from 1252. The astronomical data inscribed on the astrolabe suggest it may have been built before 1000. According to tradition, the instrument dates from the period of Charlemagne (9th C. ). A very similar Arab astrolabe is documented in a drawing by Antonio da Sangallo il Giovane [the Younger] (c.  1520?) at the Gabinetto dei Disegni e delle Stampe (Department of Drawings and Prints) of the Uffizi. Provenance: Medici collections",
"Questo astrolabio contiene attualmente due timpani, uno per le latitudini 30° e 33°, e l'altro 36° e 42° (corrispondenti alle regioni comprese tra la Persia e il Mar Nero). È completo di alidada, di regolo e di rete. Nel dorso presenta un doppio quadrato delle ombre e il calendario zodiacale. Lo strumento, proveniente dalle collezioni medicee, è completo di custodia di pelle nera lavorata (coperchio mancante) che porta all'interno una nota manoscritta del XVI secolo nella quale si ricorda che l'astrolabio fu portato dalla Spagna e che risale al 1252. I dati astronomici riportati sullo strumento suggeriscono di anticiparne la costruzione a prima del 1000. Secondo la tradizione si tratterebbe di uno strumento del tempo di Carlo Magno (IX secolo). Un astrolabio arabo molto simile a questo è documentato in un disegno di Antonio da Sangallo il Giovane (c. 1520?) conservato presso il Gabinetto dei Disegni e delle Stampe degli Uffizi. Proviene dalle collezioni medicee"
],
"contributor" : "http://minerva.atcult.it/rdf/ed494c3a-2ba6-3464-b34a-a57e4f70c5e0",
"creator" : [
"http://minerva.atcult.it/rdf/d481cbac-209b-3741-bba4-906590d805b3",
"http://minerva.atcult.it/rdf/36e6efa2-6c8f-350e-ae37-479dade48850",
"http://minerva.atcult.it/rdf/47734211-2637-3895-a690-4f33412931ec"
],
"identifier" : "000000016001",
"issued" : "sec. X",
"publisher" : "http://minerva.atcult.it/rdf/90310a84-1133-3356-bb3b-647ae1a7d14d",
"title" : "Astrolabio piano",
"numPages" : [
"1 astrolabio",
"1 astrolabe"
],
"placeOfPublication" : "Fattura araba",
"label" : "Astrolabio piano"
},
{
"#id" : "http://minerva.atcult.it/rdf/000000016002",
"#type" : [
"bibo:MultiVolumeBook",
"bibo:Book"
],
"P1053" : [
"1 astrolabe",
"1 astrolabio"
],
"abstract" : [
"Questo piccolo astrolabio contiene quattro timpani per le latitudini 24° e 30°, 31° e 35°, 32° e 36° (corrispondenti alla Persia) e per le latitudini 0° (cioè il circolo dell'equatore) e 66°. È completo di alidada e di rete. Il dorso della madre presenta il calendario lunare, secondo l'uso islamico, un quadrato delle ombre e un quadrante. Lo strumento reca la data 496 dell'Egira (1102-1103 dell'età Cristiana) ed è firmato dal suo artefice, Muhammad 'Ibn Abi'l Qasim 'Ibn Bakran, del quale non si hanno notizie. Fu donato al Museo di Storia della Scienza dal Principe fiorentino Tommaso Corsini",
"This small astrolabe carries four tympanums for latitudes 24°/30°, 31°/35°, and 32°/36° (corresponding to Persia), and for latitude 0° (i. e. , the circle of the equator) and 66°. There is an alidade and a rete. The back of the mater displays a lunar calendar, in accordance with Islamic use, a shadow square, and a quadrant. The instrument is dated 496 of the Hegira (1102-1103 of the Christian era) and is signed by its maker, Muhammad 'Ibn Abi'l Qasim 'Ibn Bakran, on whom we have no information. Donated to the Museo di Storia della Scienza by the Florentine Prince Tommaso Corsini"
],
"creator" : [
"http://minerva.atcult.it/rdf/c5738e64-fb77-354a-8fc8-47164105b5f7",
"http://minerva.atcult.it/rdf/3fa79916-cb7f-3574-a3fb-589ca42ebf17"
],
"identifier" : "000000016002",
"issued" : "1102-1103",
"publisher" : "http://minerva.atcult.it/rdf/90310a84-1133-3356-bb3b-647ae1a7d14d",
"title" : "Astrolabio piano",
"numPages" : [
"1 astrolabio",
"1 astrolabe"
],
"placeOfPublication" : "Fattura araba",
"label" : "Astrolabio piano"
},
if you need to have in a result only elements of the #graph array that match the query (if title contains word Astrolabio), you can reach that with the following aggregation framework query:
db.items.aggregate([
{$match: {"#graph.title": /Astrolabio/}},
{$unwind: "$#graph"},
{$match: {"#graph.title": /Astrolabio/} },
{$group: {"_id": "$_id", "#graph": {"$push": "$#graph" } }}
]);
your regex {$regex: /Astrolabio$/} will return only documents with titles that have 'Astrolabio' as the last word is a sentence ("Astrolabio Piano" will not be included as 'Piano' is the last word here).