You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by "hgaol (via GitHub)" <gi...@apache.org> on 2023/12/26 08:05:06 UTC

[PR] fix: update elastic search plugin to be compatible with latest search interface [incubator-answer-plugins]

hgaol opened a new pull request, #50:
URL: https://github.com/apache/incubator-answer-plugins/pull/50

   fix #49 . The current logic should be align with the tag search logic without using search plugin.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: update elastic search plugin to be compatible with latest search interface [incubator-answer-plugins]

Posted by "hgaol (via GitHub)" <gi...@apache.org>.
hgaol commented on code in PR #50:
URL: https://github.com/apache/incubator-answer-plugins/pull/50#discussion_r1436340121


##########
search-elasticsearch/es.go:
##########
@@ -246,8 +246,10 @@ func (s *SearchEngine) buildQuery(cond *plugin.SearchBasicCond) (
 	log.Debugf("build query: %+v", cond)
 
 	q := elastic.NewBoolQuery()
-	if len(cond.TagIDs) > 0 {
-		q.Must(elastic.NewTermsQuery("tags", convertToInterfaceSlice(cond.TagIDs)...))
+	for _, tagGroup := range cond.TagIDs {
+		if len(tagGroup) > 0 {
+			q.Must(elastic.NewTermsQuery("tags", convertToInterfaceSlice(tagGroup)...))

Review Comment:
   Hi, I've tested that it can achieve the result which is align with the logic in answer. For example, it'll generate below query.
   ```json
   GET /answer_post/_search
   {
     "query": {
       "bool": {
         "must": [
           {
             "terms": {
               "tags": [
                 "10030000000000002", "10030000000000001"
               ]
             }
           },
           {
             "terms": {
               "tags": [
                 "10030000000000031"
               ]
             }
           }
         ]
       }
     }
   }
   ```
   
   it means the doc contains tags with one of "10030000000000002", "10030000000000001" and contains "10030000000000031". You can find `terms` description here.
   https://www.elastic.co/guide/en/elasticsearch/reference/8.11/query-dsl-terms-query.html
   https://stackoverflow.com/questions/28768277/elasticsearch-difference-between-must-and-should-bool-query



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: update elastic search plugin to be compatible with latest search interface [incubator-answer-plugins]

Posted by "kumfo (via GitHub)" <gi...@apache.org>.
kumfo merged PR #50:
URL: https://github.com/apache/incubator-answer-plugins/pull/50


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: update elastic search plugin to be compatible with latest search interface [incubator-answer-plugins]

Posted by "kumfo (via GitHub)" <gi...@apache.org>.
kumfo commented on code in PR #50:
URL: https://github.com/apache/incubator-answer-plugins/pull/50#discussion_r1436334054


##########
search-elasticsearch/es.go:
##########
@@ -246,8 +246,10 @@ func (s *SearchEngine) buildQuery(cond *plugin.SearchBasicCond) (
 	log.Debugf("build query: %+v", cond)
 
 	q := elastic.NewBoolQuery()
-	if len(cond.TagIDs) > 0 {
-		q.Must(elastic.NewTermsQuery("tags", convertToInterfaceSlice(cond.TagIDs)...))
+	for _, tagGroup := range cond.TagIDs {
+		if len(tagGroup) > 0 {
+			q.Must(elastic.NewTermsQuery("tags", convertToInterfaceSlice(tagGroup)...))

Review Comment:
   @LinkinStars 
   Here I'm not sure if calling the same logic multiple times can achieve the desired result.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: update elastic search plugin to be compatible with latest search interface [incubator-answer-plugins]

Posted by "hgaol (via GitHub)" <gi...@apache.org>.
hgaol commented on PR #50:
URL: https://github.com/apache/incubator-answer-plugins/pull/50#issuecomment-1869348925

   Hi @kumfo , could you help to review? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org