Skip to content

Commit

Permalink
Merge pull request #51 from Klimatbyran/feat/elasticsearch-explicit-m…
Browse files Browse the repository at this point in the history
…appings

Feat/elasticsearch explicit mappings
  • Loading branch information
irony authored Mar 14, 2024
2 parents bf5fd98 + 0f32394 commit 3789e2e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
51 changes: 49 additions & 2 deletions src/elastic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Elastic {
try {
this.client = new Client({ node });
this.indexName = indexName;
this.pdfIndex = "pdfs";
this.pdfIndex = 'pdfs';
} catch (error) {
console.error('Elasticsearch constructor error:', error);
}
Expand Down Expand Up @@ -58,7 +58,54 @@ class Elastic {
properties: {
url: { type: 'keyword' },
pdfHash: { type: 'keyword' },
report: { type: 'nested' },
report: {
type: 'nested',
properties: {
companyName: { type: 'keyword' },
bransch: { type: 'keyword' },
baseYear: { type: 'keyword' },
url: { type: 'keyword' },
emissions: {
type: 'nested',
properties: {
year: { type: 'keyword' },
scope1: {
properties: {
emissions: { type: 'double' },
unit: { type: 'keyword' }
}
},
scope2: {
properties: {
emissions: { type: 'double' },
unit: { type: 'keyword' },
mb: { type: 'double' },
lb: { type: 'double' }
}
},
scope3: {
properties: {
emissions: { type: 'double' },
unit: { type: 'keyword' },
categories: {
type: 'nested',
properties: {
categoryName: { type: 'keyword' },
emissions: { type: 'double' }
}
}
}
},
totalEmissions: { type: 'double' },
totalUnit: { type: 'keyword' },
}
},
reliability: { type: 'keyword' },
needsReview: { type: 'boolean' },
reviewComment: { type: 'text' },
reviewStatusCode: { type: 'keyword' }
}
},
state: { type: 'keyword' },
timestamp: { type: 'date' }
}
Expand Down
2 changes: 2 additions & 0 deletions src/prompts/reflect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Also convert the JSON to valid json and convert all units to metric ton CO2e. We
**Data Output Format**: Present the extracted data in a structured JSON format. Include the year, Scope 1, Scope 2, Scope 3, and total emissions for each year. If possible, also include the company's name and organization number in the JSON structure.
**Important** Always generate this exact JSON structure, even if you cannot find the data. Indicate missing data with the error codes below, but make sure that the JSON structure is consistent. For example, if you cannot find the scope 3 categories you must make sure that the categories object is a valid JSON array.
Example JSON structure:
{
Expand Down

0 comments on commit 3789e2e

Please # to comment.