Update app.py
Browse files
app.py
CHANGED
|
@@ -22,9 +22,9 @@ logger = logging.getLogger(__name__)
|
|
| 22 |
app = Flask(__name__)
|
| 23 |
|
| 24 |
# ============================================
|
| 25 |
-
# PAYLOAD
|
| 26 |
# ============================================
|
| 27 |
-
|
| 28 |
"query": {
|
| 29 |
"function_score": {
|
| 30 |
"functions": [
|
|
@@ -35,7 +35,40 @@ PAYLOAD_OTIMIZADO = {
|
|
| 35 |
"filter": [
|
| 36 |
{"query_string": {
|
| 37 |
"default_operator": "AND",
|
| 38 |
-
"fields": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
"query": "*",
|
| 40 |
"type": "cross_fields",
|
| 41 |
"fuzziness": "AUTO:4,7"
|
|
@@ -46,57 +79,286 @@ PAYLOAD_OTIMIZADO = {
|
|
| 46 |
}
|
| 47 |
},
|
| 48 |
"_source": [
|
| 49 |
-
#
|
| 50 |
-
"
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
"titulo", "
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"processo_classe_processual_unificada_extenso",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
"julgamento_data",
|
| 59 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
"
|
| 63 |
-
"
|
| 64 |
-
"
|
| 65 |
-
"
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
"
|
| 69 |
-
"
|
| 70 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
# URLs
|
| 73 |
"acompanhamento_processual_url",
|
| 74 |
"dje_url",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
"documental_legislacao_citada_texto",
|
| 78 |
"documental_jurisprudencia_citada_texto",
|
|
|
|
|
|
|
| 79 |
"documental_indexacao_texto",
|
| 80 |
"documental_observacao_texto",
|
|
|
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
"documental_tese_texto",
|
| 85 |
-
"documental_tese_tema_texto"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
],
|
| 87 |
"aggs": {
|
| 88 |
"base_agg": {
|
| 89 |
"filters": {
|
| 90 |
"filters": {
|
| 91 |
-
"acordaos": {"match": {"base": "acordaos"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
| 93 |
}
|
| 94 |
}
|
| 95 |
},
|
| 96 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
"from": 0,
|
| 98 |
-
"sort": [{"julgamento_data": {"order": "desc"}}],
|
| 99 |
-
"track_total_hits":
|
| 100 |
}
|
| 101 |
|
| 102 |
# Payload para busca de um documento específico por ID
|
|
@@ -106,7 +368,8 @@ PAYLOAD_POR_ID = {
|
|
| 106 |
"values": [] # Será preenchido dinamicamente
|
| 107 |
}
|
| 108 |
},
|
| 109 |
-
"_source":
|
|
|
|
| 110 |
"size": 1
|
| 111 |
}
|
| 112 |
|
|
@@ -126,19 +389,21 @@ token_cache = {
|
|
| 126 |
"expires_at": 0
|
| 127 |
}
|
| 128 |
|
| 129 |
-
# Template HTML com
|
| 130 |
HTML_TEMPLATE = """
|
| 131 |
<!DOCTYPE html>
|
| 132 |
<html>
|
| 133 |
<head>
|
| 134 |
-
<title>⚖️ STF Jurisprudência -
|
| 135 |
<meta charset="utf-8">
|
| 136 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 137 |
<style>
|
| 138 |
-
body { font-family: 'Segoe UI', Roboto, system-ui, sans-serif; max-width:
|
| 139 |
.container { background: white; border-radius: 12px; padding: 30px; box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
|
| 140 |
h1 { color: #1a1a2e; border-bottom: 3px solid #4CAF50; padding-bottom: 15px; display: flex; align-items: center; gap: 10px; }
|
| 141 |
h1:before { content: "⚖️"; font-size: 1.2em; }
|
|
|
|
|
|
|
| 142 |
.info-box { background: #e8f0fe; border-left: 5px solid #2196F3; padding: 15px 20px; margin: 20px 0; border-radius: 8px; }
|
| 143 |
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 25px 0; }
|
| 144 |
.stat-card { background: white; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
|
|
@@ -154,30 +419,50 @@ HTML_TEMPLATE = """
|
|
| 154 |
button.download:hover { background: #e69c00; }
|
| 155 |
.loading { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3); border-top: 3px solid white; border-radius: 50%; animation: spin 1s linear infinite; margin-right: 10px; vertical-align: middle; }
|
| 156 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
| 157 |
-
pre { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; overflow: auto; max-height:
|
| 158 |
.success { color: #0f9d58; background: #e6f4ea; border-left: 5px solid #34a853; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 159 |
.error { color: #d93025; background: #fce8e6; border-left: 5px solid #ea4335; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 160 |
.warning { color: #e37400; background: #fef7e0; border-left: 5px solid #f9ab00; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 161 |
.token-box { background: #1a1a2e; color: #e0e0e0; padding: 15px; border-radius: 8px; font-family: 'Consolas', monospace; word-break: break-all; margin: 15px 0; border: 1px solid #2a2a3e; }
|
| 162 |
.token-label { color: #f9ab00; font-weight: bold; margin-bottom: 8px; display: block; }
|
| 163 |
.filters { background: #f8f9fa; border-radius: 8px; padding: 20px; margin: 20px 0; border: 1px solid #e0e0e0; }
|
| 164 |
-
.filter-group { display:
|
| 165 |
-
.filter-item {
|
| 166 |
.filter-item label { display: block; margin-bottom: 8px; color: #5f6368; font-size: 14px; font-weight: 500; }
|
| 167 |
.filter-item input, .filter-item select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
|
| 168 |
.filter-item input:focus, .filter-item select:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.2); }
|
| 169 |
.badge { display: inline-block; background: #e8f0fe; color: #1a73e8; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500; margin: 2px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
</style>
|
| 171 |
</head>
|
| 172 |
<body>
|
| 173 |
<div class="container">
|
| 174 |
-
<h1>STF Jurisprudência -
|
| 175 |
|
| 176 |
<div class="info-box">
|
| 177 |
-
<strong>📌 API de Jurisprudência do STF</strong><br>
|
| 178 |
-
•
|
| 179 |
-
•
|
| 180 |
-
•
|
| 181 |
</div>
|
| 182 |
|
| 183 |
<div class="stats-grid">
|
|
@@ -193,11 +478,11 @@ HTML_TEMPLATE = """
|
|
| 193 |
<div class="filter-item">
|
| 194 |
<label>Quantidade</label>
|
| 195 |
<select id="pageSize">
|
|
|
|
| 196 |
<option value="10">10 resultados</option>
|
| 197 |
<option value="25">25 resultados</option>
|
| 198 |
<option value="50">50 resultados</option>
|
| 199 |
<option value="100" selected>100 resultados</option>
|
| 200 |
-
<option value="250">250 resultados</option>
|
| 201 |
</select>
|
| 202 |
</div>
|
| 203 |
<div class="filter-item">
|
|
@@ -214,15 +499,23 @@ HTML_TEMPLATE = """
|
|
| 214 |
<option value="decisoes">Decisões</option>
|
| 215 |
<option value="sumulas">Súmulas</option>
|
| 216 |
<option value="informativos">Informativos</option>
|
|
|
|
| 217 |
</select>
|
| 218 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
</div>
|
| 220 |
</div>
|
| 221 |
|
| 222 |
<div class="button-group">
|
| 223 |
-
<button id="testBtn" onclick="
|
| 224 |
<span class="loading" id="loading" style="display: none;"></span>
|
| 225 |
-
<span>
|
|
|
|
|
|
|
|
|
|
| 226 |
</button>
|
| 227 |
<button id="downloadBtn" class="download" onclick="downloadJSON()" disabled>
|
| 228 |
📥 Download JSON
|
|
@@ -244,8 +537,179 @@ HTML_TEMPLATE = """
|
|
| 244 |
let lastResult = null;
|
| 245 |
let lastToken = null;
|
| 246 |
let requestsCount = 0, successCount = 0, failCount = 0, docsCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
const btn = document.getElementById('testBtn');
|
| 250 |
const loading = document.getElementById('loading');
|
| 251 |
const resultDiv = document.getElementById('result');
|
|
@@ -261,7 +725,11 @@ HTML_TEMPLATE = """
|
|
| 261 |
const response = await fetch('/api/search-advanced', {
|
| 262 |
method: 'POST',
|
| 263 |
headers: { 'Content-Type': 'application/json' },
|
| 264 |
-
body: JSON.stringify({
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
});
|
| 266 |
|
| 267 |
const data = await response.json();
|
|
@@ -290,26 +758,8 @@ HTML_TEMPLATE = """
|
|
| 290 |
document.getElementById('downloadBtn').disabled = false;
|
| 291 |
}
|
| 292 |
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
if (data.data && data.data.result) {
|
| 296 |
-
const total = data.data.result.hits.total?.value || 0;
|
| 297 |
-
const hits = data.data.result.hits.hits || [];
|
| 298 |
-
|
| 299 |
-
resultHtml += `<div class="badge">📊 Total encontrado: ${total.toLocaleString()} documentos</div>`;
|
| 300 |
-
resultHtml += `<div class="badge">📄 Exibindo: ${hits.length} resultados</div>`;
|
| 301 |
-
|
| 302 |
-
if (hits.length > 0) {
|
| 303 |
-
resultHtml += '<h4>📋 Primeiro resultado:</h4>';
|
| 304 |
-
resultHtml += '<pre>' + JSON.stringify(hits[0]._source, null, 2) + '</pre>';
|
| 305 |
-
|
| 306 |
-
if (hits.length > 1) {
|
| 307 |
-
resultHtml += `<p><em>... e mais ${hits.length - 1} resultados (veja no JSON completo)</em></p>`;
|
| 308 |
-
}
|
| 309 |
-
}
|
| 310 |
-
}
|
| 311 |
|
| 312 |
-
resultDiv.innerHTML = resultHtml;
|
| 313 |
} else {
|
| 314 |
failCount++;
|
| 315 |
document.getElementById('failCount').textContent = failCount;
|
|
@@ -333,6 +783,52 @@ HTML_TEMPLATE = """
|
|
| 333 |
}
|
| 334 |
}
|
| 335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
function downloadJSON() {
|
| 337 |
if (!lastResult) {
|
| 338 |
alert('Nenhum resultado para download');
|
|
@@ -372,6 +868,7 @@ HTML_TEMPLATE = """
|
|
| 372 |
if (data.total_docs) {
|
| 373 |
document.getElementById('totalDocs').textContent = data.total_docs.toLocaleString();
|
| 374 |
}
|
|
|
|
| 375 |
} catch (e) {
|
| 376 |
document.getElementById('totalDocs').textContent = 'indisponível';
|
| 377 |
}
|
|
@@ -436,7 +933,7 @@ def search_with_token(token, custom_payload=None):
|
|
| 436 |
if not token:
|
| 437 |
return {"success": False, "error": "Token não fornecido"}
|
| 438 |
|
| 439 |
-
payload = custom_payload or
|
| 440 |
|
| 441 |
headers = HEADERS.copy()
|
| 442 |
headers['Cookie'] = f'aws-waf-token={token}'
|
|
@@ -483,23 +980,18 @@ def search_advanced():
|
|
| 483 |
data = request.json or {}
|
| 484 |
page_size = data.get('pageSize', 100)
|
| 485 |
sort_order = data.get('sortOrder', 'desc')
|
| 486 |
-
base = data.get('base'
|
| 487 |
|
| 488 |
# Construir payload dinâmico
|
| 489 |
-
payload =
|
| 490 |
payload["size"] = min(page_size, 250) # Máximo 250
|
| 491 |
payload["sort"] = [{"julgamento_data": {"order": sort_order}}]
|
| 492 |
|
| 493 |
-
# Ajustar base na query
|
| 494 |
-
if base
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
}
|
| 498 |
-
payload["post_filter"] = {
|
| 499 |
-
"bool": {
|
| 500 |
-
"must": [{"term": {"base": base}}]
|
| 501 |
-
}
|
| 502 |
-
}
|
| 503 |
|
| 504 |
# Obter token
|
| 505 |
token = get_fresh_token()
|
|
@@ -537,10 +1029,10 @@ def search_advanced():
|
|
| 537 |
|
| 538 |
@app.route('/api/search', methods=['POST'])
|
| 539 |
def search():
|
| 540 |
-
"""Endpoint simples para busca
|
| 541 |
data = request.json or {}
|
| 542 |
token = data.get('token') or get_fresh_token()
|
| 543 |
-
custom_payload = data.get('payload',
|
| 544 |
|
| 545 |
if not token:
|
| 546 |
return jsonify({"error": "Não foi possível obter token"}), 500
|
|
@@ -587,7 +1079,7 @@ def test_bypass():
|
|
| 587 |
# Tentar primeiro com token
|
| 588 |
token = get_fresh_token()
|
| 589 |
if token:
|
| 590 |
-
result = search_with_token(token,
|
| 591 |
if result.get("success"):
|
| 592 |
return jsonify({
|
| 593 |
"success": True,
|
|
@@ -598,7 +1090,7 @@ def test_bypass():
|
|
| 598 |
})
|
| 599 |
|
| 600 |
# Fallback para Playwright
|
| 601 |
-
return test_with_playwright_full(
|
| 602 |
|
| 603 |
def test_with_playwright_full(payload):
|
| 604 |
"""Versão completa do Playwright para fallback"""
|
|
@@ -746,8 +1238,9 @@ if __name__ == '__main__':
|
|
| 746 |
|
| 747 |
logger.info("="*50)
|
| 748 |
logger.info("🚀 Iniciando aplicação STF Jurisprudência")
|
| 749 |
-
logger.info("📦 Payload
|
| 750 |
-
logger.info(f"📋 Campos
|
|
|
|
| 751 |
logger.info("="*50)
|
| 752 |
|
| 753 |
# Verificar Playwright
|
|
@@ -760,3 +1253,4 @@ if __name__ == '__main__':
|
|
| 760 |
|
| 761 |
port = int(os.environ.get('PORT', 7860))
|
| 762 |
app.run(host='0.0.0.0', port=port, debug=False)
|
|
|
|
|
|
| 22 |
app = Flask(__name__)
|
| 23 |
|
| 24 |
# ============================================
|
| 25 |
+
# PAYLOAD COMPLETO com TODOS os campos
|
| 26 |
# ============================================
|
| 27 |
+
PAYLOAD_COMPLETO = {
|
| 28 |
"query": {
|
| 29 |
"function_score": {
|
| 30 |
"functions": [
|
|
|
|
| 35 |
"filter": [
|
| 36 |
{"query_string": {
|
| 37 |
"default_operator": "AND",
|
| 38 |
+
"fields": [
|
| 39 |
+
"processo_codigo_completo.plural",
|
| 40 |
+
"acordao_ata.plural^3",
|
| 41 |
+
"documental_acordao_mesmo_sentido_lista_texto.plural",
|
| 42 |
+
"documental_doutrina_texto.plural",
|
| 43 |
+
"documental_indexacao_texto.plural",
|
| 44 |
+
"documental_jurisprudencia_citada_texto.plural",
|
| 45 |
+
"documental_legislacao_citada_texto.plural",
|
| 46 |
+
"documental_observacao_texto.plural",
|
| 47 |
+
"documental_publicacao_lista_texto.plural",
|
| 48 |
+
"documental_tese_tema_texto.plural^3",
|
| 49 |
+
"documental_tese_texto.plural^3",
|
| 50 |
+
"ementa_texto.plural^3",
|
| 51 |
+
"ministro_facet.plural",
|
| 52 |
+
"revisor_processo_nome.plural",
|
| 53 |
+
"orgao_julgador.plural",
|
| 54 |
+
"partes_lista_texto.plural",
|
| 55 |
+
"procedencia_geografica_completo.plural",
|
| 56 |
+
"processo_classe_processual_unificada_extenso.plural",
|
| 57 |
+
"titulo.plural^6",
|
| 58 |
+
"colac_numero.plural",
|
| 59 |
+
"colac_pagina.plural",
|
| 60 |
+
"decisao_texto.plural^2",
|
| 61 |
+
"documental_decisao_mesmo_sentido_lista_texto.plural",
|
| 62 |
+
"processo_precedente_texto.plural",
|
| 63 |
+
"sumula_texto.plural^3",
|
| 64 |
+
"ramo_direito.plural^1",
|
| 65 |
+
"situacao_sumula.plural^1",
|
| 66 |
+
"materia_noticia.plural^1",
|
| 67 |
+
"titulo_noticia.plural^3",
|
| 68 |
+
"resumo_noticia.plural^3",
|
| 69 |
+
"conteudo_noticia.plural^1",
|
| 70 |
+
"ramo_noticia.plural^1"
|
| 71 |
+
],
|
| 72 |
"query": "*",
|
| 73 |
"type": "cross_fields",
|
| 74 |
"fuzziness": "AUTO:4,7"
|
|
|
|
| 79 |
}
|
| 80 |
},
|
| 81 |
"_source": [
|
| 82 |
+
# Campos básicos de identificação
|
| 83 |
+
"base", "_id", "id", "dg_unique",
|
| 84 |
|
| 85 |
+
# Título e metadados principais
|
| 86 |
+
"titulo", "ministro_facet", "orgao_julgador",
|
| 87 |
+
|
| 88 |
+
# Procedência geográfica
|
| 89 |
+
"procedencia_geografica_completo",
|
| 90 |
+
"procedencia_geografica_pais_sigla",
|
| 91 |
+
"procedencia_geografica_uf_sigla",
|
| 92 |
+
"procedencia_geografica_uf_extenso",
|
| 93 |
+
|
| 94 |
+
# Processo
|
| 95 |
+
"processo_codigo_completo",
|
| 96 |
"processo_classe_processual_unificada_extenso",
|
| 97 |
+
"processo_classe_processual_unificada_classe_sigla",
|
| 98 |
+
"processo_classe_processual_unificada_incidente_sigla",
|
| 99 |
+
"processo_classe_processual_unificada_sigla",
|
| 100 |
+
"processo_numero",
|
| 101 |
+
"processo_lista_texto",
|
| 102 |
|
| 103 |
+
# Datas
|
| 104 |
+
"julgamento_data",
|
| 105 |
+
"publicacao_data",
|
| 106 |
+
"republicacao_data",
|
| 107 |
+
"periodo_inicio_data",
|
| 108 |
+
"periodo_fim_data",
|
| 109 |
+
"dg_atualizado_em",
|
| 110 |
|
| 111 |
+
# Decisão e presidência
|
| 112 |
+
"is_decisao_presidencia",
|
| 113 |
+
"relator_processo_nome",
|
| 114 |
+
"relator_decisao_nome",
|
| 115 |
+
"relator_acordao_nome",
|
| 116 |
+
"presidente_nome",
|
| 117 |
+
"revisor_processo_nome",
|
| 118 |
|
| 119 |
+
# Textos completos
|
| 120 |
+
"ementa_texto",
|
| 121 |
+
"acordao_ata",
|
| 122 |
+
"decisao_texto",
|
| 123 |
+
"inteiro_teor_url",
|
| 124 |
+
"sumula_texto",
|
| 125 |
+
|
| 126 |
+
# Partes
|
| 127 |
+
"partes_lista_texto",
|
| 128 |
|
| 129 |
+
# URLs
|
| 130 |
"acompanhamento_processual_url",
|
| 131 |
"dje_url",
|
| 132 |
+
"informativo_url",
|
| 133 |
+
"pesquisa_url",
|
| 134 |
+
"audio_url",
|
| 135 |
+
"video_url",
|
| 136 |
+
"numero_noticias_url",
|
| 137 |
+
"aprovacao_url",
|
| 138 |
|
| 139 |
+
# Publicações
|
| 140 |
+
"documental_publicacao_lista_texto",
|
| 141 |
+
|
| 142 |
+
# Decisões relacionadas
|
| 143 |
+
"documental_decisao_mesmo_sentido_lista_texto",
|
| 144 |
+
"documental_decisao_mesmo_sentido_lista_html",
|
| 145 |
+
"documental_decisao_mesmo_sentido_is_secundario",
|
| 146 |
+
|
| 147 |
+
# Legislação e jurisprudência citada
|
| 148 |
"documental_legislacao_citada_texto",
|
| 149 |
"documental_jurisprudencia_citada_texto",
|
| 150 |
+
|
| 151 |
+
# Indexação e observações
|
| 152 |
"documental_indexacao_texto",
|
| 153 |
"documental_observacao_texto",
|
| 154 |
+
"documental_observacao_html",
|
| 155 |
|
| 156 |
+
# Doutrina
|
| 157 |
+
"documental_doutrina_texto",
|
| 158 |
+
|
| 159 |
+
# Acórdãos relacionados
|
| 160 |
+
"documental_acordao_mesmo_sentido_lista_texto",
|
| 161 |
+
"documental_acordao_mesmo_sentido_lista_html",
|
| 162 |
+
"documental_acordao_mesmo_sentido_is_secundario",
|
| 163 |
+
|
| 164 |
+
# Assuntos e teses
|
| 165 |
+
"documental_assunto_texto",
|
| 166 |
+
"documental_tese_tipo",
|
| 167 |
"documental_tese_texto",
|
| 168 |
+
"documental_tese_tema_texto",
|
| 169 |
+
|
| 170 |
+
# Objeto externo
|
| 171 |
+
"externo_seq_objeto_incidente",
|
| 172 |
+
|
| 173 |
+
# Volume informativo
|
| 174 |
+
"volume_informativo",
|
| 175 |
+
|
| 176 |
+
# Notícias
|
| 177 |
+
"ramo_noticia",
|
| 178 |
+
"materia_noticia",
|
| 179 |
+
"titulo_noticia",
|
| 180 |
+
"resumo_noticia",
|
| 181 |
+
"conteudo_noticia",
|
| 182 |
+
"numero_noticias_processo",
|
| 183 |
+
|
| 184 |
+
# COVID-19
|
| 185 |
+
"is_covid",
|
| 186 |
+
|
| 187 |
+
# Tipo de julgamento
|
| 188 |
+
"tipo_julgamento",
|
| 189 |
+
"julgamento_is_sessao_virtual",
|
| 190 |
+
|
| 191 |
+
# Súmulas
|
| 192 |
+
"sumula_numero",
|
| 193 |
+
"is_vinculante",
|
| 194 |
+
"situacao_sumula",
|
| 195 |
+
|
| 196 |
+
# Ramo do direito
|
| 197 |
+
"ramo_direito",
|
| 198 |
+
|
| 199 |
+
# Precedentes
|
| 200 |
+
"processo_precedente_texto",
|
| 201 |
+
"processo_precedente_html",
|
| 202 |
+
|
| 203 |
+
# Flags booleanas
|
| 204 |
+
"is_questao_ordem",
|
| 205 |
+
"is_repercussao_geral_admissibilidade",
|
| 206 |
+
"is_repercussao_geral_merito",
|
| 207 |
+
"is_repercussao_geral_recurso_interno",
|
| 208 |
+
"is_repercussao_geral",
|
| 209 |
+
"is_processo_antigo",
|
| 210 |
+
"is_colac",
|
| 211 |
+
|
| 212 |
+
# COLAC
|
| 213 |
+
"colac_numero",
|
| 214 |
+
"colac_pagina",
|
| 215 |
+
|
| 216 |
+
# IDs antigos
|
| 217 |
+
"old_seq_colac",
|
| 218 |
+
"old_seq_repercussao_geral",
|
| 219 |
+
"old_seq_sjur",
|
| 220 |
+
|
| 221 |
+
# ODS (Objetivos de Desenvolvimento Sustentável)
|
| 222 |
+
"ods_onu"
|
| 223 |
],
|
| 224 |
"aggs": {
|
| 225 |
"base_agg": {
|
| 226 |
"filters": {
|
| 227 |
"filters": {
|
| 228 |
+
"acordaos": {"match": {"base": "acordaos"}},
|
| 229 |
+
"sumulas": {"match": {"base": "sumulas"}},
|
| 230 |
+
"decisoes": {"match": {"base": "decisoes"}},
|
| 231 |
+
"informativos": {"match": {"base": "novo_informativo"}}
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
},
|
| 235 |
+
"orgao_julgador_agg": {
|
| 236 |
+
"aggs": {
|
| 237 |
+
"orgao_julgador_agg": {
|
| 238 |
+
"terms": {"field": "orgao_julgador.keyword", "size": 10}
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
},
|
| 242 |
+
"ministro_facet_agg": {
|
| 243 |
+
"aggs": {
|
| 244 |
+
"ministro_facet_agg": {
|
| 245 |
+
"terms": {"field": "ministro_facet.keyword", "size": 10}
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
},
|
| 249 |
+
"procedencia_geografica_uf_sigla_agg": {
|
| 250 |
+
"aggs": {
|
| 251 |
+
"procedencia_geografica_uf_sigla_agg": {
|
| 252 |
+
"terms": {"field": "procedencia_geografica_uf_sigla", "size": 10}
|
| 253 |
}
|
| 254 |
}
|
| 255 |
}
|
| 256 |
},
|
| 257 |
+
"highlight": {
|
| 258 |
+
"fields": {
|
| 259 |
+
"ementa_texto": {
|
| 260 |
+
"matched_fields": ["ementa_texto.plural"],
|
| 261 |
+
"type": "fvh",
|
| 262 |
+
"fragment_size": 24000
|
| 263 |
+
},
|
| 264 |
+
"sumula_texto": {
|
| 265 |
+
"matched_fields": ["sumula_texto.plural"],
|
| 266 |
+
"type": "fvh",
|
| 267 |
+
"number_of_fragments": 0
|
| 268 |
+
},
|
| 269 |
+
"materia_noticia": {
|
| 270 |
+
"matched_fields": ["materia_noticia.plural"],
|
| 271 |
+
"type": "fvh"
|
| 272 |
+
},
|
| 273 |
+
"titulo_noticia": {
|
| 274 |
+
"matched_fields": ["titulo_noticia.plural"],
|
| 275 |
+
"type": "fvh"
|
| 276 |
+
},
|
| 277 |
+
"resumo_noticia": {
|
| 278 |
+
"matched_fields": ["resumo_noticia.plural"],
|
| 279 |
+
"type": "fvh",
|
| 280 |
+
"fragment_size": 5000
|
| 281 |
+
},
|
| 282 |
+
"conteudo_noticia": {
|
| 283 |
+
"matched_fields": ["conteudo_noticia.plural"],
|
| 284 |
+
"type": "fvh",
|
| 285 |
+
"fragment_size": 50000
|
| 286 |
+
},
|
| 287 |
+
"acordao_ata": {
|
| 288 |
+
"matched_fields": ["acordao_ata.plural"],
|
| 289 |
+
"type": "fvh",
|
| 290 |
+
"fragment_size": 600
|
| 291 |
+
},
|
| 292 |
+
"decisao_texto": {
|
| 293 |
+
"matched_fields": ["decisao_texto.plural"],
|
| 294 |
+
"type": "fvh",
|
| 295 |
+
"fragment_size": 1200
|
| 296 |
+
},
|
| 297 |
+
"documental_tese_texto": {
|
| 298 |
+
"matched_fields": ["documental_tese_texto.plural"],
|
| 299 |
+
"type": "fvh",
|
| 300 |
+
"fragment_size": 2000
|
| 301 |
+
},
|
| 302 |
+
"documental_tese_tema_texto": {
|
| 303 |
+
"matched_fields": ["documental_tese_tema_texto.plural"],
|
| 304 |
+
"type": "fvh",
|
| 305 |
+
"fragment_size": 2000
|
| 306 |
+
},
|
| 307 |
+
"documental_observacao_texto": {
|
| 308 |
+
"matched_fields": ["documental_observacao_texto.plural"],
|
| 309 |
+
"type": "fvh"
|
| 310 |
+
},
|
| 311 |
+
"documental_indexacao_texto": {
|
| 312 |
+
"matched_fields": ["documental_indexacao_texto.plural"],
|
| 313 |
+
"type": "fvh"
|
| 314 |
+
},
|
| 315 |
+
"documental_legislacao_citada_texto": {
|
| 316 |
+
"matched_fields": ["documental_legislacao_citada_texto.plural"],
|
| 317 |
+
"type": "fvh"
|
| 318 |
+
},
|
| 319 |
+
"documental_jurisprudencia_citada_texto": {
|
| 320 |
+
"matched_fields": ["documental_jurisprudencia_citada_texto.plural"],
|
| 321 |
+
"type": "fvh"
|
| 322 |
+
},
|
| 323 |
+
"documental_doutrina_texto": {
|
| 324 |
+
"matched_fields": ["documental_doutrina_texto.plural"],
|
| 325 |
+
"type": "fvh"
|
| 326 |
+
},
|
| 327 |
+
"partes_lista_texto": {
|
| 328 |
+
"matched_fields": ["partes_lista_texto.plural"],
|
| 329 |
+
"type": "fvh"
|
| 330 |
+
},
|
| 331 |
+
"documental_publicacao_lista_texto": {
|
| 332 |
+
"matched_fields": ["documental_publicacao_lista_texto.plural"],
|
| 333 |
+
"type": "fvh"
|
| 334 |
+
},
|
| 335 |
+
"documental_acordao_mesmo_sentido_lista_texto": {
|
| 336 |
+
"matched_fields": ["documental_acordao_mesmo_sentido_lista_texto.plural"],
|
| 337 |
+
"type": "fvh"
|
| 338 |
+
},
|
| 339 |
+
"documental_decisao_mesmo_sentido_lista_texto": {
|
| 340 |
+
"matched_fields": ["documental_decisao_mesmo_sentido_lista_texto.plural"],
|
| 341 |
+
"type": "fvh"
|
| 342 |
+
},
|
| 343 |
+
"processo_precedente_texto": {
|
| 344 |
+
"matched_fields": ["processo_precedente_texto.plural"],
|
| 345 |
+
"type": "fvh"
|
| 346 |
+
},
|
| 347 |
+
"procedencia_geografica_completo": {
|
| 348 |
+
"matched_fields": ["procedencia_geografica_completo.plural"],
|
| 349 |
+
"type": "fvh"
|
| 350 |
+
}
|
| 351 |
+
},
|
| 352 |
+
"pre_tags": ["<em>"],
|
| 353 |
+
"post_tags": ["</em>"],
|
| 354 |
+
"fragment_size": 300,
|
| 355 |
+
"number_of_fragments": 64,
|
| 356 |
+
"order": "score"
|
| 357 |
+
},
|
| 358 |
+
"size": 100,
|
| 359 |
"from": 0,
|
| 360 |
+
"sort": [{"julgamento_data": {"order": "desc"}}],
|
| 361 |
+
"track_total_hits": true
|
| 362 |
}
|
| 363 |
|
| 364 |
# Payload para busca de um documento específico por ID
|
|
|
|
| 368 |
"values": [] # Será preenchido dinamicamente
|
| 369 |
}
|
| 370 |
},
|
| 371 |
+
"_source": PAYLOAD_COMPLETO["_source"],
|
| 372 |
+
"highlight": PAYLOAD_COMPLETO["highlight"],
|
| 373 |
"size": 1
|
| 374 |
}
|
| 375 |
|
|
|
|
| 389 |
"expires_at": 0
|
| 390 |
}
|
| 391 |
|
| 392 |
+
# Template HTML com visualização completa dos campos
|
| 393 |
HTML_TEMPLATE = """
|
| 394 |
<!DOCTYPE html>
|
| 395 |
<html>
|
| 396 |
<head>
|
| 397 |
+
<title>⚖️ STF Jurisprudência - Visualizador Completo</title>
|
| 398 |
<meta charset="utf-8">
|
| 399 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 400 |
<style>
|
| 401 |
+
body { font-family: 'Segoe UI', Roboto, system-ui, sans-serif; max-width: 1600px; margin: 0 auto; padding: 20px; background: #f0f2f5; }
|
| 402 |
.container { background: white; border-radius: 12px; padding: 30px; box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
|
| 403 |
h1 { color: #1a1a2e; border-bottom: 3px solid #4CAF50; padding-bottom: 15px; display: flex; align-items: center; gap: 10px; }
|
| 404 |
h1:before { content: "⚖️"; font-size: 1.2em; }
|
| 405 |
+
h2 { color: #2c3e50; margin-top: 25px; margin-bottom: 15px; font-size: 1.5em; border-left: 5px solid #4CAF50; padding-left: 15px; }
|
| 406 |
+
h3 { color: #34495e; margin-top: 20px; margin-bottom: 10px; font-size: 1.2em; border-bottom: 1px solid #e0e0e0; padding-bottom: 8px; }
|
| 407 |
.info-box { background: #e8f0fe; border-left: 5px solid #2196F3; padding: 15px 20px; margin: 20px 0; border-radius: 8px; }
|
| 408 |
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 25px 0; }
|
| 409 |
.stat-card { background: white; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
|
|
|
|
| 419 |
button.download:hover { background: #e69c00; }
|
| 420 |
.loading { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3); border-top: 3px solid white; border-radius: 50%; animation: spin 1s linear infinite; margin-right: 10px; vertical-align: middle; }
|
| 421 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
| 422 |
+
pre { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; overflow: auto; max-height: 800px; font-size: 13px; font-family: 'Consolas', 'Monaco', monospace; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
|
| 423 |
.success { color: #0f9d58; background: #e6f4ea; border-left: 5px solid #34a853; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 424 |
.error { color: #d93025; background: #fce8e6; border-left: 5px solid #ea4335; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 425 |
.warning { color: #e37400; background: #fef7e0; border-left: 5px solid #f9ab00; padding: 15px 20px; margin: 15px 0; border-radius: 8px; font-weight: 500; }
|
| 426 |
.token-box { background: #1a1a2e; color: #e0e0e0; padding: 15px; border-radius: 8px; font-family: 'Consolas', monospace; word-break: break-all; margin: 15px 0; border: 1px solid #2a2a3e; }
|
| 427 |
.token-label { color: #f9ab00; font-weight: bold; margin-bottom: 8px; display: block; }
|
| 428 |
.filters { background: #f8f9fa; border-radius: 8px; padding: 20px; margin: 20px 0; border: 1px solid #e0e0e0; }
|
| 429 |
+
.filter-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; align-items: end; }
|
| 430 |
+
.filter-item { min-width: 200px; }
|
| 431 |
.filter-item label { display: block; margin-bottom: 8px; color: #5f6368; font-size: 14px; font-weight: 500; }
|
| 432 |
.filter-item input, .filter-item select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
|
| 433 |
.filter-item input:focus, .filter-item select:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.2); }
|
| 434 |
.badge { display: inline-block; background: #e8f0fe; color: #1a73e8; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500; margin: 2px; }
|
| 435 |
+
.campo-lista { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 15px; margin: 10px 0; }
|
| 436 |
+
.campo-nome { font-weight: bold; color: #2c3e50; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
|
| 437 |
+
.campo-valor { color: #1a1a2e; font-size: 14px; word-break: break-word; font-family: 'Consolas', monospace; background: white; padding: 8px; border-radius: 4px; border: 1px solid #e0e0e0; }
|
| 438 |
+
.campo-vazio { color: #999; font-style: italic; }
|
| 439 |
+
.texto-completo { max-height: 400px; overflow-y: auto; background: #f1f8fe; padding: 15px; border-radius: 8px; border: 1px solid #b8daf5; margin: 10px 0; white-space: pre-wrap; font-family: inherit; line-height: 1.5; }
|
| 440 |
+
.nav-tabs { display: flex; gap: 5px; margin: 20px 0; flex-wrap: wrap; border-bottom: 2px solid #e0e0e0; padding-bottom: 10px; }
|
| 441 |
+
.nav-tab { padding: 10px 20px; cursor: pointer; background: white; border: 1px solid #e0e0e0; border-radius: 8px 8px 0 0; margin-bottom: -2px; font-weight: 500; transition: all 0.2s; }
|
| 442 |
+
.nav-tab:hover { background: #f0f0f0; }
|
| 443 |
+
.nav-tab.active { background: #1a73e8; color: white; border-color: #1a73e8; }
|
| 444 |
+
.tab-content { display: none; padding: 20px; background: white; border: 1px solid #e0e0e0; border-top: none; border-radius: 0 0 8px 8px; }
|
| 445 |
+
.tab-content.active { display: block; }
|
| 446 |
+
.campo-card { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 15px; margin: 10px 0; transition: all 0.2s; }
|
| 447 |
+
.campo-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: #1a73e8; }
|
| 448 |
+
.flag-true { color: #0f9d58; font-weight: bold; }
|
| 449 |
+
.flag-false { color: #d93025; }
|
| 450 |
+
.url-link { color: #1a73e8; text-decoration: none; word-break: break-all; }
|
| 451 |
+
.url-link:hover { text-decoration: underline; }
|
| 452 |
+
.highlight { background-color: #f9ab00; color: #1a1a2e; font-weight: bold; padding: 2px 4px; border-radius: 4px; }
|
| 453 |
+
.highlight-box { background: #fef7e0; border: 1px solid #f9ab00; padding: 10px; border-radius: 8px; margin: 10px 0; }
|
| 454 |
+
.highlight-title { font-weight: bold; color: #e37400; margin-bottom: 5px; }
|
| 455 |
</style>
|
| 456 |
</head>
|
| 457 |
<body>
|
| 458 |
<div class="container">
|
| 459 |
+
<h1>STF Jurisprudência - Visualizador Completo</h1>
|
| 460 |
|
| 461 |
<div class="info-box">
|
| 462 |
+
<strong>📌 API de Jurisprudência do STF - Todos os Campos com Highlight</strong><br>
|
| 463 |
+
• Total de campos disponíveis: <span id="totalCampos">102</span><br>
|
| 464 |
+
• Campos com highlight: 22 campos configurados<br>
|
| 465 |
+
• Documentos disponíveis: <span id="totalDocs">carregando...</span>
|
| 466 |
</div>
|
| 467 |
|
| 468 |
<div class="stats-grid">
|
|
|
|
| 478 |
<div class="filter-item">
|
| 479 |
<label>Quantidade</label>
|
| 480 |
<select id="pageSize">
|
| 481 |
+
<option value="5">5 resultados</option>
|
| 482 |
<option value="10">10 resultados</option>
|
| 483 |
<option value="25">25 resultados</option>
|
| 484 |
<option value="50">50 resultados</option>
|
| 485 |
<option value="100" selected>100 resultados</option>
|
|
|
|
| 486 |
</select>
|
| 487 |
</div>
|
| 488 |
<div class="filter-item">
|
|
|
|
| 499 |
<option value="decisoes">Decisões</option>
|
| 500 |
<option value="sumulas">Súmulas</option>
|
| 501 |
<option value="informativos">Informativos</option>
|
| 502 |
+
<option value="">Todas</option>
|
| 503 |
</select>
|
| 504 |
</div>
|
| 505 |
+
<div class="filter-item">
|
| 506 |
+
<label>Busca por ID</label>
|
| 507 |
+
<input type="text" id="docId" placeholder="Ex: sjur505215">
|
| 508 |
+
</div>
|
| 509 |
</div>
|
| 510 |
</div>
|
| 511 |
|
| 512 |
<div class="button-group">
|
| 513 |
+
<button id="testBtn" onclick="runSearch()">
|
| 514 |
<span class="loading" id="loading" style="display: none;"></span>
|
| 515 |
+
<span>🔍 Buscar Documentos</span>
|
| 516 |
+
</button>
|
| 517 |
+
<button id="getByIdBtn" class="secondary" onclick="getDocumentById()">
|
| 518 |
+
<span>📄 Buscar por ID</span>
|
| 519 |
</button>
|
| 520 |
<button id="downloadBtn" class="download" onclick="downloadJSON()" disabled>
|
| 521 |
📥 Download JSON
|
|
|
|
| 537 |
let lastResult = null;
|
| 538 |
let lastToken = null;
|
| 539 |
let requestsCount = 0, successCount = 0, failCount = 0, docsCount = 0;
|
| 540 |
+
let currentTab = 'visao-geral';
|
| 541 |
+
|
| 542 |
+
function renderCampo(nome, valor, tipo = 'normal') {
|
| 543 |
+
if (valor === null || valor === undefined || valor === '') {
|
| 544 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="campo-vazio">(vazio)</div></div>`;
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
if (tipo === 'url' && valor) {
|
| 548 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="campo-valor"><a href="${valor}" target="_blank" class="url-link">${valor}</a></div></div>`;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
if (tipo === 'flag') {
|
| 552 |
+
const flagClass = valor ? 'flag-true' : 'flag-false';
|
| 553 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="campo-valor ${flagClass}">${valor ? '✓ Sim' : '✗ Não'}</div></div>`;
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
if (tipo === 'texto' && valor && valor.length > 200) {
|
| 557 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="texto-completo">${valor.replace(/\\n/g, '<br>').replace(/<em>/g, '<span class="highlight">').replace(/<\\/em>/g, '</span>')}</div></div>`;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
if (Array.isArray(valor)) {
|
| 561 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="campo-valor">${valor.join('<br>')}</div></div>`;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
return `<div class="campo-card"><div class="campo-nome">${nome}</div><div class="campo-valor">${String(valor).replace(/\\n/g, '<br>').replace(/<em>/g, '<span class="highlight">').replace(/<\\/em>/g, '</span>')}</div></div>`;
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
function renderHighlight(highlight) {
|
| 568 |
+
if (!highlight) return '';
|
| 569 |
+
|
| 570 |
+
let html = '<div class="highlight-box"><div class="highlight-title">🔆 Termos destacados (highlight):</div>';
|
| 571 |
+
for (const [campo, valores] of Object.entries(highlight)) {
|
| 572 |
+
if (valores && valores.length > 0) {
|
| 573 |
+
html += `<div><strong>${campo}:</strong> `;
|
| 574 |
+
valores.forEach(valor => {
|
| 575 |
+
html += `<div style="margin-left: 20px; margin-top: 5px;">${valor.replace(/<em>/g, '<span class="highlight">').replace(/<\\/em>/g, '</span>')}</div>`;
|
| 576 |
+
});
|
| 577 |
+
html += '</div>';
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
html += '</div>';
|
| 581 |
+
return html;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
function displayResult(data) {
|
| 585 |
+
if (!data || !data.result || !data.result.hits || !data.result.hits.hits || data.result.hits.hits.length === 0) {
|
| 586 |
+
document.getElementById('result').innerHTML = '<div class="warning">⚠️ Nenhum documento encontrado</div>';
|
| 587 |
+
return;
|
| 588 |
+
}
|
| 589 |
|
| 590 |
+
const hits = data.result.hits.hits;
|
| 591 |
+
const total = data.result.hits.total?.value || 0;
|
| 592 |
+
|
| 593 |
+
let html = `<div class="success">✅ Encontrados ${total.toLocaleString()} documentos. Exibindo ${hits.length} resultados.</div>`;
|
| 594 |
+
|
| 595 |
+
hits.forEach((hit, index) => {
|
| 596 |
+
const source = hit._source || {};
|
| 597 |
+
const highlight = hit.highlight || {};
|
| 598 |
+
const docId = source.id || hit._id || `doc_${index}`;
|
| 599 |
+
|
| 600 |
+
html += `<div class="campo-lista" style="margin-top: 30px;">`;
|
| 601 |
+
html += `<h3 style="display: flex; justify-content: space-between; align-items: center;">
|
| 602 |
+
<span>📄 Documento ${index + 1}: ${source.titulo || source.processo_codigo_completo || docId}</span>
|
| 603 |
+
<span class="badge">ID: ${docId}</span>
|
| 604 |
+
</h3>`;
|
| 605 |
+
|
| 606 |
+
// Abas internas para cada documento
|
| 607 |
+
html += `<div style="display: flex; gap: 5px; margin: 15px 0; flex-wrap: wrap;">`;
|
| 608 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('geral-${index}')">📋 Geral</button>`;
|
| 609 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('ementa-${index}')">📝 Ementa</button>`;
|
| 610 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('acordao-${index}')">⚖️ Acórdão</button>`;
|
| 611 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('legislacao-${index}')">📚 Legislação</button>`;
|
| 612 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('highlight-${index}')">🔆 Highlight</button>`;
|
| 613 |
+
html += `<button class="badge" style="cursor: pointer;" onclick="showDocTab('completo-${index}')">📋 Todos Campos</button>`;
|
| 614 |
+
html += `</div>`;
|
| 615 |
+
|
| 616 |
+
// Aba: Geral
|
| 617 |
+
html += `<div id="doc-tab-geral-${index}" class="doc-tab" style="display: block;">`;
|
| 618 |
+
html += renderCampo('Processo', source.processo_codigo_completo);
|
| 619 |
+
html += renderCampo('Classe', source.processo_classe_processual_unificada_extenso);
|
| 620 |
+
html += renderCampo('Órgão Julgador', source.orgao_julgador);
|
| 621 |
+
html += renderCampo('Relator', source.relator_processo_nome);
|
| 622 |
+
html += renderCampo('Relator Acórdão', source.relator_acordao_nome);
|
| 623 |
+
html += renderCampo('Ministros', source.ministro_facet);
|
| 624 |
+
html += renderCampo('Data Julgamento', source.julgamento_data);
|
| 625 |
+
html += renderCampo('Data Publicação', source.publicacao_data);
|
| 626 |
+
html += renderCampo('Procedência', source.procedencia_geografica_completo);
|
| 627 |
+
html += renderCampo('UF', source.procedencia_geografica_uf_sigla);
|
| 628 |
+
html += `</div>`;
|
| 629 |
+
|
| 630 |
+
// Aba: Ementa
|
| 631 |
+
html += `<div id="doc-tab-ementa-${index}" class="doc-tab" style="display: none;">`;
|
| 632 |
+
html += renderCampo('Ementa', source.ementa_texto, 'texto');
|
| 633 |
+
html += renderCampo('Tese', source.documental_tese_texto, 'texto');
|
| 634 |
+
html += renderCampo('Tema', source.documental_tese_tema_texto);
|
| 635 |
+
html += `</div>`;
|
| 636 |
+
|
| 637 |
+
// Aba: Acórdão
|
| 638 |
+
html += `<div id="doc-tab-acordao-${index}" class="doc-tab" style="display: none;">`;
|
| 639 |
+
html += renderCampo('Acórdão/Ata', source.acordao_ata, 'texto');
|
| 640 |
+
html += renderCampo('Decisão', source.decisao_texto, 'texto');
|
| 641 |
+
html += renderCampo('Súmula', source.sumula_texto, 'texto');
|
| 642 |
+
html += renderCampo('Indexação', source.documental_indexacao_texto, 'texto');
|
| 643 |
+
html += renderCampo('Observações', source.documental_observacao_texto, 'texto');
|
| 644 |
+
html += `</div>`;
|
| 645 |
+
|
| 646 |
+
// Aba: Legislação
|
| 647 |
+
html += `<div id="doc-tab-legislacao-${index}" class="doc-tab" style="display: none;">`;
|
| 648 |
+
html += renderCampo('Legislação Citada', source.documental_legislacao_citada_texto, 'texto');
|
| 649 |
+
html += renderCampo('Jurisprudência Citada', source.documental_jurisprudencia_citada_texto, 'texto');
|
| 650 |
+
html += renderCampo('Doutrina', source.documental_doutrina_texto, 'texto');
|
| 651 |
+
html += renderCampo('Precedentes', source.processo_precedente_texto, 'texto');
|
| 652 |
+
html += `</div>`;
|
| 653 |
+
|
| 654 |
+
// Aba: Highlight
|
| 655 |
+
html += `<div id="doc-tab-highlight-${index}" class="doc-tab" style="display: none;">`;
|
| 656 |
+
if (Object.keys(highlight).length > 0) {
|
| 657 |
+
for (const [campo, valores] of Object.entries(highlight)) {
|
| 658 |
+
if (valores && valores.length > 0) {
|
| 659 |
+
html += `<div class="campo-card">`;
|
| 660 |
+
html += `<div class="campo-nome">${campo}</div>`;
|
| 661 |
+
valores.forEach(valor => {
|
| 662 |
+
html += `<div class="highlight-box" style="margin-top: 5px;">${valor.replace(/<em>/g, '<span class="highlight">').replace(/<\\/em>/g, '</span>')}</div>`;
|
| 663 |
+
});
|
| 664 |
+
html += `</div>`;
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
} else {
|
| 668 |
+
html += `<div class="campo-vazio">Nenhum termo destacado</div>`;
|
| 669 |
+
}
|
| 670 |
+
html += `</div>`;
|
| 671 |
+
|
| 672 |
+
// Aba: Todos Campos
|
| 673 |
+
html += `<div id="doc-tab-completo-${index}" class="doc-tab" style="display: none;">`;
|
| 674 |
+
html += `<pre>${JSON.stringify(source, null, 2).replace(/<em>/g, '<span class="highlight">').replace(/<\\/em>/g, '</span>')}</pre>`;
|
| 675 |
+
html += `</div>`;
|
| 676 |
+
|
| 677 |
+
// URLs importantes
|
| 678 |
+
if (source.inteiro_teor_url) {
|
| 679 |
+
html += `<div style="margin-top: 15px; padding: 10px; background: #e8f0fe; border-radius: 8px;">`;
|
| 680 |
+
html += `<strong>🔗 Links:</strong><br>`;
|
| 681 |
+
html += `<a href="${source.inteiro_teor_url}" target="_blank" class="url-link">📄 Inteiro Teor</a><br>`;
|
| 682 |
+
if (source.acompanhamento_processual_url) {
|
| 683 |
+
html += `<a href="${source.acompanhamento_processual_url}" target="_blank" class="url-link">📊 Acompanhamento Processual</a><br>`;
|
| 684 |
+
}
|
| 685 |
+
if (source.dje_url) {
|
| 686 |
+
html += `<a href="${source.dje_url}" target="_blank" class="url-link">📰 DJE</a>`;
|
| 687 |
+
}
|
| 688 |
+
html += `</div>`;
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
html += `</div>`; // Fecha campo-lista
|
| 692 |
+
});
|
| 693 |
+
|
| 694 |
+
document.getElementById('result').innerHTML = html;
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
function showDocTab(tabId) {
|
| 698 |
+
const docIndex = tabId.split('-')[2];
|
| 699 |
+
// Esconder todas as abas deste documento
|
| 700 |
+
document.querySelectorAll(`[id^="doc-tab-"]`).forEach(el => {
|
| 701 |
+
if (el.id.includes(`-${docIndex}`)) {
|
| 702 |
+
el.style.display = 'none';
|
| 703 |
+
}
|
| 704 |
+
});
|
| 705 |
+
// Mostrar a aba selecionada
|
| 706 |
+
const selectedTab = document.getElementById(`doc-tab-${tabId}`);
|
| 707 |
+
if (selectedTab) {
|
| 708 |
+
selectedTab.style.display = 'block';
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
async function runSearch() {
|
| 713 |
const btn = document.getElementById('testBtn');
|
| 714 |
const loading = document.getElementById('loading');
|
| 715 |
const resultDiv = document.getElementById('result');
|
|
|
|
| 725 |
const response = await fetch('/api/search-advanced', {
|
| 726 |
method: 'POST',
|
| 727 |
headers: { 'Content-Type': 'application/json' },
|
| 728 |
+
body: JSON.stringify({
|
| 729 |
+
pageSize: parseInt(pageSize),
|
| 730 |
+
sortOrder,
|
| 731 |
+
base: base || undefined
|
| 732 |
+
})
|
| 733 |
});
|
| 734 |
|
| 735 |
const data = await response.json();
|
|
|
|
| 758 |
document.getElementById('downloadBtn').disabled = false;
|
| 759 |
}
|
| 760 |
|
| 761 |
+
displayResult(data.data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
|
|
|
|
| 763 |
} else {
|
| 764 |
failCount++;
|
| 765 |
document.getElementById('failCount').textContent = failCount;
|
|
|
|
| 783 |
}
|
| 784 |
}
|
| 785 |
|
| 786 |
+
async function getDocumentById() {
|
| 787 |
+
const docId = document.getElementById('docId').value.trim();
|
| 788 |
+
if (!docId) {
|
| 789 |
+
alert('Digite um ID');
|
| 790 |
+
return;
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
const btn = document.getElementById('getByIdBtn');
|
| 794 |
+
const loading = document.getElementById('loading');
|
| 795 |
+
const resultDiv = document.getElementById('result');
|
| 796 |
+
|
| 797 |
+
btn.disabled = true;
|
| 798 |
+
loading.style.display = 'inline-block';
|
| 799 |
+
resultDiv.innerHTML = '<div class="info-box">⏳ Buscando documento...</div>';
|
| 800 |
+
|
| 801 |
+
try {
|
| 802 |
+
const response = await fetch(`/api/document/${docId}`);
|
| 803 |
+
const data = await response.json();
|
| 804 |
+
|
| 805 |
+
requestsCount++;
|
| 806 |
+
document.getElementById('requestsCount').textContent = requestsCount;
|
| 807 |
+
|
| 808 |
+
if (data.success && data.document) {
|
| 809 |
+
successCount++;
|
| 810 |
+
document.getElementById('successCount').textContent = successCount;
|
| 811 |
+
docsCount++;
|
| 812 |
+
document.getElementById('docsCount').textContent = docsCount;
|
| 813 |
+
|
| 814 |
+
lastResult = { result: { hits: { hits: [data.document] } } };
|
| 815 |
+
|
| 816 |
+
displayResult(lastResult);
|
| 817 |
+
} else {
|
| 818 |
+
failCount++;
|
| 819 |
+
document.getElementById('failCount').textContent = failCount;
|
| 820 |
+
resultDiv.innerHTML = '<div class="error">❌ Documento não encontrado</div>';
|
| 821 |
+
}
|
| 822 |
+
} catch (error) {
|
| 823 |
+
failCount++;
|
| 824 |
+
document.getElementById('failCount').textContent = failCount;
|
| 825 |
+
resultDiv.innerHTML = '<div class="error">❌ Erro: ' + error.message + '</div>';
|
| 826 |
+
} finally {
|
| 827 |
+
btn.disabled = false;
|
| 828 |
+
loading.style.display = 'none';
|
| 829 |
+
}
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
function downloadJSON() {
|
| 833 |
if (!lastResult) {
|
| 834 |
alert('Nenhum resultado para download');
|
|
|
|
| 868 |
if (data.total_docs) {
|
| 869 |
document.getElementById('totalDocs').textContent = data.total_docs.toLocaleString();
|
| 870 |
}
|
| 871 |
+
document.getElementById('totalCampos').textContent = "102";
|
| 872 |
} catch (e) {
|
| 873 |
document.getElementById('totalDocs').textContent = 'indisponível';
|
| 874 |
}
|
|
|
|
| 933 |
if not token:
|
| 934 |
return {"success": False, "error": "Token não fornecido"}
|
| 935 |
|
| 936 |
+
payload = custom_payload or PAYLOAD_COMPLETO
|
| 937 |
|
| 938 |
headers = HEADERS.copy()
|
| 939 |
headers['Cookie'] = f'aws-waf-token={token}'
|
|
|
|
| 980 |
data = request.json or {}
|
| 981 |
page_size = data.get('pageSize', 100)
|
| 982 |
sort_order = data.get('sortOrder', 'desc')
|
| 983 |
+
base = data.get('base')
|
| 984 |
|
| 985 |
# Construir payload dinâmico
|
| 986 |
+
payload = PAYLOAD_COMPLETO.copy()
|
| 987 |
payload["size"] = min(page_size, 250) # Máximo 250
|
| 988 |
payload["sort"] = [{"julgamento_data": {"order": sort_order}}]
|
| 989 |
|
| 990 |
+
# Ajustar base na query se especificada
|
| 991 |
+
if base:
|
| 992 |
+
if "post_filter" not in payload:
|
| 993 |
+
payload["post_filter"] = {"bool": {"must": []}}
|
| 994 |
+
payload["post_filter"]["bool"]["must"] = [{"term": {"base": base}}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 995 |
|
| 996 |
# Obter token
|
| 997 |
token = get_fresh_token()
|
|
|
|
| 1029 |
|
| 1030 |
@app.route('/api/search', methods=['POST'])
|
| 1031 |
def search():
|
| 1032 |
+
"""Endpoint simples para busca"""
|
| 1033 |
data = request.json or {}
|
| 1034 |
token = data.get('token') or get_fresh_token()
|
| 1035 |
+
custom_payload = data.get('payload', PAYLOAD_COMPLETO)
|
| 1036 |
|
| 1037 |
if not token:
|
| 1038 |
return jsonify({"error": "Não foi possível obter token"}), 500
|
|
|
|
| 1079 |
# Tentar primeiro com token
|
| 1080 |
token = get_fresh_token()
|
| 1081 |
if token:
|
| 1082 |
+
result = search_with_token(token, PAYLOAD_COMPLETO)
|
| 1083 |
if result.get("success"):
|
| 1084 |
return jsonify({
|
| 1085 |
"success": True,
|
|
|
|
| 1090 |
})
|
| 1091 |
|
| 1092 |
# Fallback para Playwright
|
| 1093 |
+
return test_with_playwright_full(PAYLOAD_COMPLETO)
|
| 1094 |
|
| 1095 |
def test_with_playwright_full(payload):
|
| 1096 |
"""Versão completa do Playwright para fallback"""
|
|
|
|
| 1238 |
|
| 1239 |
logger.info("="*50)
|
| 1240 |
logger.info("🚀 Iniciando aplicação STF Jurisprudência")
|
| 1241 |
+
logger.info("📦 Payload completo com todos os campos")
|
| 1242 |
+
logger.info(f"📋 Campos _source: {len(PAYLOAD_COMPLETO['_source'])}")
|
| 1243 |
+
logger.info(f"🔆 Campos highlight: {len(PAYLOAD_COMPLETO['highlight']['fields'])}")
|
| 1244 |
logger.info("="*50)
|
| 1245 |
|
| 1246 |
# Verificar Playwright
|
|
|
|
| 1253 |
|
| 1254 |
port = int(os.environ.get('PORT', 7860))
|
| 1255 |
app.run(host='0.0.0.0', port=port, debug=False)
|
| 1256 |
+
|