Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imlement scoring in elk for search elements #148

Merged
merged 20 commits into from
Jul 10, 2024

Conversation

jamal-khey
Copy link
Contributor

@jamal-khey jamal-khey commented Jun 21, 2024

to test this PR run :

curl -XDELETE localhost:9200/directory-elements
restart directory-server
curl -XPOST localhost:5026/v1/supervision/elements/reindex

to test and adjust boost go to : http://localhost:5601/app/dev_tools#/console

in the elastic search does not recommend using wildcard with a * in the beging, because This can increase the iterations needed to find matching terms and slow search performance.

to find how the score is computed use GET /directory-elements/_explain/doccumentId

GET /directory-elements/_search
{
  "query": {
    "bool": {
      "must_not": {
        "term": {
          "type.keyword": "DIRECTORY"
        }
      },
      "must": {
        "wildcard": {
          "name.fullascii": "*jamal-filtre*"
        }
      },
      "should": [
        {
          "match": {
            "name.fullascii": {
              "query": "jamal-filtre",
              "boost": 4
            }
          }
        },
        {
          "terms": {
            "fullPathUuid": ["b4aaa9c2-9c78-40ac-958a-2a9144ddfbcc"],
            "boost": 1.0
          }
        },
        {
          "match": {
            "parentId": {
              "query": "b4aaa9c2-9c78-40ac-958a-2a9144ddfbcc",
              "boost": 1
            }
          }
        }
      ]
    }
  }
}

…search

# Conflicts:
#	src/main/java/org/gridsuite/directory/server/repository/DirectoryElementRepository.java
#	src/main/java/org/gridsuite/directory/server/services/DirectoryRepositoryService.java
@jamal-khey jamal-khey changed the title imlement scoring for search elements imlement scoring in elk for search elements Jun 21, 2024
@SlimaneAmar
Copy link
Contributor

I think the best mapping of a path is with field type : keyword
https://www.elastic.co/fr/blog/strings-are-dead-long-live-strings

@SlimaneAmar
Copy link
Contributor

Need complete tests for scoring with all cases

@@ -58,6 +58,9 @@ public class DirectoryElementInfos {
@Field(type = FieldType.Date, format = DateFormat.date_time)
Instant lastModificationDate;

@Field(type = FieldType.Text)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@jamal-khey jamal-khey requested a review from SlimaneAmar July 5, 2024 07:25
.toList();
public List<DirectoryElementInfos> searchElements(@NonNull String userInput, String directoryUuid) {
return directoryElementInfosService.searchElements(userInput, directoryUuid)
.stream().filter(element -> isElementExists(element.getParentId())) // filter the Orphan elements
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SlimaneAmar in case of deletion of a directory , we can still have Orphans

//                              root
        //                    /                           \
        // dir1 (deleted but keeping its sub-elements)     dir2
        directoryElementRepository.deleteById(subDirUuid1);`

Slimane AMAR and others added 3 commits July 9, 2024 10:55
Copy link

sonarqubecloud bot commented Jul 9, 2024

public List<DirectoryElementInfos> searchElements(@NonNull String userInput, String currentDirectoryUuid) {

// We dont want to show the directories
Query directory = TermQuery.of(m -> m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queries.termQuery(ELEMENT_TYPE, DIRECTORY)._toQuery() ?

@jamal-khey jamal-khey merged commit 99e9411 into main Jul 10, 2024
4 checks passed
@jamal-khey jamal-khey deleted the jamal-khey/store-path-in-elastic-search branch July 10, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants