dadoonet commented on issue #15196:
URL: https://github.com/apache/lucene/issues/15196#issuecomment-3432392265

   After talking with @romseygeek, it appears that's it's super easy to solve 
using the existing features, here a [Mapping Char 
Filter](https://www.elastic.co/docs/reference/text-analysis/analysis-mapping-charfilter):
   
   ```
   DELETE /my-index-000001
   PUT /my-index-000001
   {
     "settings": {
       "analysis": {
         "analyzer": {
           "fscrawler_path": {
             "tokenizer": "fscrawler_path",
             "char_filter": [
               "windows_separator"
             ]
           }
         },
         "char_filter": {
           "windows_separator": {
             "type": "mapping",
             "mappings": [
               "\\\\ => /"
             ]
           }
         },
         "tokenizer": {
           "fscrawler_path": {
             "type": "path_hierarchy"
           }
         }
       }
     }
   }
   POST /my-index-000001/_analyze
   {
       "analyzer": "fscrawler_path",
       "text": ["/tmp/test", "\\tmp\\test"]
   }
   ```
   
   This gives a consistent result for both Linux and Windows paths:
   
   ```json
   {
     "tokens": [
       {
         "token": "/tmp",
         "start_offset": 0,
         "end_offset": 4,
         "type": "word",
         "position": 0
       },
       {
         "token": "/tmp/test",
         "start_offset": 0,
         "end_offset": 9,
         "type": "word",
         "position": 1
       },
       {
         "token": "/tmp",
         "start_offset": 10,
         "end_offset": 14,
         "type": "word",
         "position": 102
       },
       {
         "token": "/tmp/test",
         "start_offset": 10,
         "end_offset": 19,
         "type": "word",
         "position": 103
       }
     ]
   }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to